Commits

Cat's Eye Technologies committed 096ce3d

One major bug fixed: method.run() was not returning its result.

Comments (0)

Files changed (2)

impl/velo.lua/src/velo.lua

     end
 
     methods.to_s = function()
-        return "Lookup(" .. _receiver.to_s() .. "," .. _ident .. ")"
+        return "Lookup(" .. _receiver.to_s() .. ",'" .. _ident .. "')"
     end
 
     return methods
     local methods = {}
 
     methods.eval = function(obj, args)
-        debug("eval #{self} on " .. obj.to_s() .. " with #{args}")
+        debug("eval " .. methods.to_s() .. " on " .. obj.to_s() .. " with " .. #args .. " args")
         local new_args = {}
         for i,expr in ipairs(exprs) do
             new_args[#new_args+1] = expr.eval(obj, args)
                method_expr.to_s() .. " -> " .. method.to_s())
         if method.class == "VeloMethod" then
             --# xxx show receiver (method's bound object) in debug
-            debug "running real method #{method} w/args #{args}"
+            debug("running real method " .. method.to_s() .. " w/arg count " .. #args)
             return method.run(new_args)
         else
             debug("just returning non-method (" .. method.to_s() .. ") on call")
     end
 
     methods.to_s = function()
-        return "StringLiteral(" .. text .. ")"
+        return "StringLiteral('" .. text .. "')"
     end
     
     return methods
     end
 
     methods.run = function(args)
-        fun(_obj, args)
+        return fun(_obj, args)
     end
 
     methods.to_s = function()
         ]]--
         trail[#trail+1] = methods
         if attrs[ident] ~= nil then
-            debug("found here " .. methods.to_s() .. ", it's #{@attrs[ident]}")
+            debug("found here " .. methods.to_s() .. ", it's " .. attrs[ident].to_s())
             return attrs[ident]
         else
             local x = nil
 String = VeloObject.new 'String'
 
 String.set('concat', VeloMethod.new('concat', function(obj, args)
-  debug "concat #{obj} #{args[0]}"
-  return make_string_literal(obj.contents() .. args[1].contents())
+    debug("concat " .. obj.to_s())-- .. ", " .. args[1].to_s())
+    return make_string_literal(obj.contents() .. args[1].contents())
 end))
 
 String.set('create', VeloMethod.new('create', function(obj, args)
-  local p = Parser.new(obj.contents())
-  local s = p.script()
-  debug("create! " .. obj.to_s())-- .. ", " .. args[1].to_s())
-  s.eval(args[1], {})
-  return args[1]
+    local p = Parser.new(obj.contents())
+    local s = p.script()
+    debug("create! " .. obj.to_s())-- .. ", " .. args[1].to_s())
+    s.eval(args[1], {})
+    return args[1]
 end))
 
 String.set('method', VeloMethod.new('method', function(obj, args)
 
         local p = Parser.new(text)
         local s = p.script()
-        if ast then
+        if dump_ast then
             print(s.to_s())
         else
             local o = VeloObject.new('main-script')

src/velo/runtime.rb

 $String.set 'create', VeloMethod.new('create', proc { |obj, args|
   p = Parser.new obj.contents
   s = p.script
+  debug "create! #{s} #{args[0]} arg count #{args.length}"
   s.eval args[0], []
   args[0]
 })