minor
This commit is contained in:
@ -14,18 +14,19 @@ module Ast
|
||||
save_locals context , into
|
||||
call.load_args into
|
||||
call.do_call into
|
||||
resore_locals context , into
|
||||
restore_locals context , into
|
||||
function.return_type
|
||||
end
|
||||
|
||||
def save_locals context , into
|
||||
into.instance_eval do
|
||||
push [:r0, :r1 , :r2]
|
||||
push [:r1 , :r2 , :r3]
|
||||
end
|
||||
end
|
||||
|
||||
def resore_locals context , into
|
||||
def restore_locals context , into
|
||||
into.instance_eval do
|
||||
pop [:r0, :r1 , :r2]
|
||||
pop [:r1, :r2 , :r3]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -38,7 +38,7 @@ module Ast
|
||||
body.each do |b|
|
||||
compiled = b.compile(context , into)
|
||||
function.return_type = compiled
|
||||
puts "compiled in function #{compiled.inspect}"
|
||||
puts "compiled in function #{compiled.class}"
|
||||
raise "alarm #{compiled} \n #{b}" unless compiled.is_a? Vm::Word
|
||||
end
|
||||
context.locals = parent_locals
|
||||
|
@ -21,7 +21,8 @@ module Elf
|
||||
|
||||
binary = program.assemble(StringIO.new )
|
||||
|
||||
blocks = program.functions.collect{ |f| [f.entry , f.exit , f.body] }
|
||||
# blocks = program.functions.collect{ |f| [f.entry , f.exit , f.body] }
|
||||
blocks = program.functions.collect{ |f| [f.body] }
|
||||
blocks += [program.entry , program.exit , program.main]
|
||||
blocks.flatten.each do |b|
|
||||
add_symbol b.name.to_s , b.position
|
||||
|
Reference in New Issue
Block a user