One major bug fixed: method.run() was not returning its result.
Cat's Eye Technologies
11 years ago
114 | 114 | end |
115 | 115 | |
116 | 116 | methods.to_s = function() |
117 | return "Lookup(" .. _receiver.to_s() .. "," .. _ident .. ")" | |
117 | return "Lookup(" .. _receiver.to_s() .. ",'" .. _ident .. "')" | |
118 | 118 | end |
119 | 119 | |
120 | 120 | return methods |
125 | 125 | local methods = {} |
126 | 126 | |
127 | 127 | methods.eval = function(obj, args) |
128 | debug("eval #{self} on " .. obj.to_s() .. " with #{args}") | |
128 | debug("eval " .. methods.to_s() .. " on " .. obj.to_s() .. " with " .. #args .. " args") | |
129 | 129 | local new_args = {} |
130 | 130 | for i,expr in ipairs(exprs) do |
131 | 131 | new_args[#new_args+1] = expr.eval(obj, args) |
136 | 136 | method_expr.to_s() .. " -> " .. method.to_s()) |
137 | 137 | if method.class == "VeloMethod" then |
138 | 138 | --# xxx show receiver (method's bound object) in debug |
139 | debug "running real method #{method} w/args #{args}" | |
139 | debug("running real method " .. method.to_s() .. " w/arg count " .. #args) | |
140 | 140 | return method.run(new_args) |
141 | 141 | else |
142 | 142 | debug("just returning non-method (" .. method.to_s() .. ") on call") |
182 | 182 | end |
183 | 183 | |
184 | 184 | methods.to_s = function() |
185 | return "StringLiteral(" .. text .. ")" | |
185 | return "StringLiteral('" .. text .. "')" | |
186 | 186 | end |
187 | 187 | |
188 | 188 | return methods |
574 | 574 | end |
575 | 575 | |
576 | 576 | methods.run = function(args) |
577 | fun(_obj, args) | |
577 | return fun(_obj, args) | |
578 | 578 | end |
579 | 579 | |
580 | 580 | methods.to_s = function() |
640 | 640 | ]]-- |
641 | 641 | trail[#trail+1] = methods |
642 | 642 | if attrs[ident] ~= nil then |
643 | debug("found here " .. methods.to_s() .. ", it's #{@attrs[ident]}") | |
643 | debug("found here " .. methods.to_s() .. ", it's " .. attrs[ident].to_s()) | |
644 | 644 | return attrs[ident] |
645 | 645 | else |
646 | 646 | local x = nil |
698 | 698 | String = VeloObject.new 'String' |
699 | 699 | |
700 | 700 | String.set('concat', VeloMethod.new('concat', function(obj, args) |
701 | debug "concat #{obj} #{args[0]}" | |
702 | return make_string_literal(obj.contents() .. args[1].contents()) | |
701 | debug("concat " .. obj.to_s())-- .. ", " .. args[1].to_s()) | |
702 | return make_string_literal(obj.contents() .. args[1].contents()) | |
703 | 703 | end)) |
704 | 704 | |
705 | 705 | String.set('create', VeloMethod.new('create', function(obj, args) |
706 | local p = Parser.new(obj.contents()) | |
707 | local s = p.script() | |
708 | debug("create! " .. obj.to_s())-- .. ", " .. args[1].to_s()) | |
709 | s.eval(args[1], {}) | |
710 | return args[1] | |
706 | local p = Parser.new(obj.contents()) | |
707 | local s = p.script() | |
708 | debug("create! " .. obj.to_s())-- .. ", " .. args[1].to_s()) | |
709 | s.eval(args[1], {}) | |
710 | return args[1] | |
711 | 711 | end)) |
712 | 712 | |
713 | 713 | String.set('method', VeloMethod.new('method', function(obj, args) |
774 | 774 | |
775 | 775 | local p = Parser.new(text) |
776 | 776 | local s = p.script() |
777 | if ast then | |
777 | if dump_ast then | |
778 | 778 | print(s.to_s()) |
779 | 779 | else |
780 | 780 | local o = VeloObject.new('main-script') |