class Cauldron::VarCollectOperator
Public Class Methods
new(indexes)
click to toggle source
# File lib/cauldron/operator/var_collect_operator.rb, line 5 def initialize(indexes) @indexes = indexes end
Public Instance Methods
build(children, scope)
click to toggle source
# File lib/cauldron/operator/var_collect_operator.rb, line 23 def build(children, scope) to_sexp(scope, children) end
to_ruby(contents, variables)
click to toggle source
# File lib/cauldron/operator/var_collect_operator.rb, line 9 def to_ruby(contents, variables) Sorcerer.source self.to_sexp( contents ,variables) end
to_sexp(scope, operators)
click to toggle source
# File lib/cauldron/operator/var_collect_operator.rb, line 13 def to_sexp(scope, operators) scope_var = scope.new_variable! second_scope_var = scope.new_variable! if operators.empty? return [:stmts_add, [:stmts_new], [:assign, [:var_field, [:@ident, scope_var ]], [:method_add_block, [:call, [:vcall, [:@ident, scope[@indexes[0]]]], :".", [:@ident, "collect"]], [:do_block, [:block_var, [:params, [[:@ident, second_scope_var]], nil, nil, nil, nil, nil, nil], false], [:stmts_add, [:stmts_new], [:var_ref, [:@ident, second_scope_var]]]]]]] else return [:stmts_add, [:stmts_new], [:assign, [:var_field, [:@ident, scope_var ]], [:method_add_block, [:call, [:vcall, [:@ident, scope[@indexes[0]]]], :".", [:@ident, "collect"]], [:do_block, [:block_var, [:params, [[:@ident, second_scope_var]], nil, nil, nil, nil, nil, nil], false], [:stmts_add, [:stmts_new], operators.first.content.build([], scope) ]]]]] end end