reduce method return type to type and introduce a single instruction for instance get

This commit is contained in:
Torsten Ruger
2014-07-14 21:28:21 +03:00
parent b1893482ff
commit b59a9da34e
11 changed files with 51 additions and 19 deletions

View File

@ -63,7 +63,18 @@ module Ast
end
end
class AssignmentExpression < Expression
#attr_reader :left, :right
def compile frame , method
raise "must assign to NameExpression , not #{left}" unless left.instance_of? NameExpression
r = right.compile(frame,method)
frame.compile_set( method , left.name , r )
end
end
class VariableExpression < NameExpression
def compile frame ,method
Virtual::ObjectGet.new(name)
end
end
end

View File

@ -53,12 +53,4 @@ module Ast
end
end
class VariableExpression < CallSiteExpression
# super( :_get_instance_variable , [StringExpression.new(name)] )
def make_setter
@name = :_set_instance_variable
@args << StringExpression.new("value")
end
end
end

View File

@ -2,7 +2,9 @@ module Ast
class IfExpression < Expression
# attr_reader :cond, :if_true, :if_false
def compile frame , method
return nil
Virtual::Reference
end
def old
f = context.function
# to execute the logic as the if states it, the blocks are the other way around
# so we can the jump over the else if true ,and the else joins unconditionally after the true_block

View File

@ -2,7 +2,7 @@ module Ast
class OperatorExpression < Expression
# attr_reader :operator, :left, :right
def compile frame , method
nil
Virtual::Reference.new
end
def scratch
into = context.function

View File

@ -2,7 +2,7 @@ module Ast
class ReturnExpression < Expression
# attr_reader :expression
def compile frame ,method
nil
Virtual::Reference.new
end
def sc
into = context.function

View File

@ -2,7 +2,7 @@ module Ast
class WhileExpression < Expression
# attr_reader :condition, :body
def compile frame , method
nil
Virtual::Reference.new
end
def old
into = context.function