remove tmp variables
sadly without having to touch tests
This commit is contained in:
parent
5a2a857485
commit
dba94827ec
@ -28,9 +28,8 @@ module Parfait
|
|||||||
raise "Wrong type, expect List not #{arg_names.class}" unless arg_names.is_a? List
|
raise "Wrong type, expect List not #{arg_names.class}" unless arg_names.is_a? List
|
||||||
self.arg_names = arg_names
|
self.arg_names = arg_names
|
||||||
self.locals = List.new
|
self.locals = List.new
|
||||||
self.tmps = List.new
|
|
||||||
end
|
end
|
||||||
attributes [:name , :arg_names , :for_class , :code , :locals , :tmps]
|
attributes [:name , :arg_names , :for_class , :code , :locals ]
|
||||||
|
|
||||||
|
|
||||||
# determine whether this method has a variable by the given name
|
# determine whether this method has a variable by the given name
|
||||||
@ -54,7 +53,6 @@ module Parfait
|
|||||||
def has_local name
|
def has_local name
|
||||||
raise "has_local #{name}.#{name.class}" unless name.is_a? Symbol
|
raise "has_local #{name}.#{name.class}" unless name.is_a? Symbol
|
||||||
index = self.locals.index_of(name)
|
index = self.locals.index_of(name)
|
||||||
index = self.tmps.index_of(name) unless index
|
|
||||||
index
|
index
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ module Virtual
|
|||||||
# instances are copied (shame on you)
|
# instances are copied (shame on you)
|
||||||
:Class => [:object_layout , :name , :instance_methods , :super_class , :meta_class],
|
:Class => [:object_layout , :name , :instance_methods , :super_class , :meta_class],
|
||||||
:Dictionary => [:keys , :values ] ,
|
:Dictionary => [:keys , :values ] ,
|
||||||
:Method => [:name , :code ,:arg_names , :for_class, :locals , :tmps ] ,
|
:Method => [:name , :code ,:arg_names , :for_class, :locals ] ,
|
||||||
:Module => [:name , :instance_methods , :super_class , :meta_class ]
|
:Module => [:name , :instance_methods , :super_class , :meta_class ]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -117,12 +117,6 @@ module Virtual
|
|||||||
return new_b
|
return new_b
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_tmp
|
|
||||||
name = "__tmp__#{@tmps.length}"
|
|
||||||
@tmps << name
|
|
||||||
Ast::NameExpression.new(name)
|
|
||||||
end
|
|
||||||
|
|
||||||
# sugar to create instructions easily.
|
# sugar to create instructions easily.
|
||||||
# any method will be passed on to the RegisterMachine and the result added to the insertion block
|
# any method will be passed on to the RegisterMachine and the result added to the insertion block
|
||||||
# With this trick we can write what looks like assembler,
|
# With this trick we can write what looks like assembler,
|
||||||
|
@ -8,7 +8,7 @@ module Virtual
|
|||||||
# save return register to the message at instance return_address
|
# save return register to the message at instance return_address
|
||||||
new_codes << Register.save_return(code, :message , :return_address)
|
new_codes << Register.save_return(code, :message , :return_address)
|
||||||
# and create a new frame if needed
|
# and create a new frame if needed
|
||||||
unless code.method.locals.empty? and code.method.tmps.empty?
|
unless code.method.locals.empty?
|
||||||
new_codes << Virtual::NewFrame.new
|
new_codes << Virtual::NewFrame.new
|
||||||
end
|
end
|
||||||
block.replace(code , new_codes )
|
block.replace(code , new_codes )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user