git @ Cat's Eye Technologies Velo / e3dacb6
One major bug fixed: method.run() was not returning its result. Cat's Eye Technologies 11 years ago
2 changed file(s) with 15 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
114114 end
115115
116116 methods.to_s = function()
117 return "Lookup(" .. _receiver.to_s() .. "," .. _ident .. ")"
117 return "Lookup(" .. _receiver.to_s() .. ",'" .. _ident .. "')"
118118 end
119119
120120 return methods
125125 local methods = {}
126126
127127 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")
129129 local new_args = {}
130130 for i,expr in ipairs(exprs) do
131131 new_args[#new_args+1] = expr.eval(obj, args)
136136 method_expr.to_s() .. " -> " .. method.to_s())
137137 if method.class == "VeloMethod" then
138138 --# 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)
140140 return method.run(new_args)
141141 else
142142 debug("just returning non-method (" .. method.to_s() .. ") on call")
182182 end
183183
184184 methods.to_s = function()
185 return "StringLiteral(" .. text .. ")"
185 return "StringLiteral('" .. text .. "')"
186186 end
187187
188188 return methods
574574 end
575575
576576 methods.run = function(args)
577 fun(_obj, args)
577 return fun(_obj, args)
578578 end
579579
580580 methods.to_s = function()
640640 ]]--
641641 trail[#trail+1] = methods
642642 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())
644644 return attrs[ident]
645645 else
646646 local x = nil
698698 String = VeloObject.new 'String'
699699
700700 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())
703703 end))
704704
705705 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]
711711 end))
712712
713713 String.set('method', VeloMethod.new('method', function(obj, args)
774774
775775 local p = Parser.new(text)
776776 local s = p.script()
777 if ast then
777 if dump_ast then
778778 print(s.to_s())
779779 else
780780 local o = VeloObject.new('main-script')
140140 $String.set 'create', VeloMethod.new('create', proc { |obj, args|
141141 p = Parser.new obj.contents
142142 s = p.script
143 debug "create! #{s} #{args[0]} arg count #{args.length}"
143144 s.eval args[0], []
144145 args[0]
145146 })