lib/qed/evaluator.rb in qed-2.2.0 vs lib/qed/evaluator.rb in qed-2.2.1

- old
+ new

@@ -6,16 +6,17 @@ class Evaluator # def initialize(script, *observers) @script = script - @file = script.file @ast = script.parse - @scope = script.scope - @binding = script.binding - @advice = script.advice + #@file = script.file + #@scope = script.scope + #@binding = script.binding + #@advice = script.advice + @observers = observers end # def run @@ -36,22 +37,21 @@ end end # def evaluate_code(section) - advise!(:before_code, section, @file) + advise!(:before_code, section, @script.file) begin advise!(:code, section) - eval(section.text, @binding, @file, section.line) - #@scope.module_eval(section.text, @file, section.line) + @script.evaluate(section.text, section.line) pass!(section) rescue Assertion => exception fail!(section, exception) rescue Exception => exception error!(section, exception) end - advise!(:after_code, section, @file) + advise!(:after_code, section, @script.file) end # def evaluate_text(section) advise!(:text, section) @@ -95,18 +95,17 @@ end # def import!(file) advise!(:unload) - eval(File.read(file), @binding, file) + eval(File.read(file), @script.binding, file) advise!(:load, file) end - # + # Dispatch event to observers and advice. def advise!(signal, *args) @observers.each{ |o| o.update(signal, *args) } - #@scope.__advice__.call(signal, *args) - @advice.call(@scope, signal, *args) + @script.advise(signal, *args) end # #def advise_when!(match) # @advice.call_when(match)