clean up block names and export of qualified names makes assembler nicer to read

This commit is contained in:
Torsten Ruger 2014-05-31 17:02:55 +03:00
parent 5756e0b325
commit 4038bd331a
5 changed files with 12 additions and 8 deletions

View File

@ -27,7 +27,7 @@ module Ast
args << arg_value args << arg_value
end end
class_name = context.current_class.name class_name = context.current_class.name
function = Vm::Function.new("#{class_name}::#{name}" , args ) function = Vm::Function.new(name , args )
context.current_class.add_function function context.current_class.add_function function
parent_locals = context.locals parent_locals = context.locals

View File

@ -23,7 +23,11 @@ module Elf
blocks = [] blocks = []
program.classes.values.each do |clazz| program.classes.values.each do |clazz|
clazz.functions.each {|f| blocks += f.blocks } clazz.functions.each do |f|
f.blocks.each do |b|
add_symbol "#{clazz.name}::#{f.name}@#{b.name}" , b.position
end
end
end end
blocks += [program.entry , program.exit , program.main] blocks += [program.entry , program.exit , program.main]
blocks.flatten.each do |b| blocks.flatten.each do |b|

View File

@ -9,7 +9,7 @@ module Parser
space? >> right_parenthesis space? >> right_parenthesis
} }
rule(:call_site) { name.as(:call_site) >> argument_list >> comment.maybe} rule(:call_site) { (name.as(:receiver) >> str(".")).repeat(0,1) >> name.as(:call_site) >> argument_list >> comment.maybe}
end end

View File

@ -26,7 +26,7 @@ module Vm
fun = get_function name fun = get_function name
unless fun unless fun
fun = Core::Kernel.send(name , @context) fun = Core::Kernel.send(name , @context)
raise "no such function '#{name}'" if fun == nil raise "no such function #{name}, #{name.class}" if fun == nil
@functions << fun @functions << fun
end end
fun fun

View File

@ -40,10 +40,10 @@ module Vm
end end
end end
set_return return_type set_return return_type
@exit = Core::Kernel::function_exit( Vm::Block.new("#{name}_exit" , self) , name ) @exit = Core::Kernel::function_exit( Vm::Block.new("exit" , self) , name )
@return = Block.new("#{name}_return", self , @exit) @return = Block.new("return", self , @exit)
@body = Block.new("#{name}_body", self , @return) @body = Block.new("body", self , @return)
@entry = Core::Kernel::function_entry( Vm::Block.new("#{name}_entry" , self , @body) ,name ) @entry = Core::Kernel::function_entry( Vm::Block.new("entry" , self , @body) ,name )
@locals = [] @locals = []
@blocks = [] @blocks = []
end end