retiring ClassField and class_field from typed layer
Creating classes is the responsibility of melon
This commit is contained in:
@ -2,7 +2,7 @@ require_relative "tree"
|
||||
|
||||
module Typed
|
||||
|
||||
CompilerModules = [ "assignment" , "basic_values" , "call_site", "class_field" ,
|
||||
CompilerModules = [ "assignment" , "basic_values" , "call_site",
|
||||
"class_statement" , "collections" , "field_def" , "field_access",
|
||||
"function_statement" , "if_statement" , "name_expression" ,
|
||||
"operator_expression" , "return_statement", "statement_list",
|
||||
@ -92,7 +92,7 @@ module Typed
|
||||
# class_name and method_name are pretty clear, args are given as a ruby array
|
||||
def create_method( class_name , method_name , args = {})
|
||||
raise "create_method #{class_name}.#{class_name.class}" unless class_name.is_a? Symbol
|
||||
clazz = Register.machine.space.get_class_by_name class_name
|
||||
clazz = Register.machine.space.get_class_by_name! class_name
|
||||
raise "No such class #{class_name}" unless clazz
|
||||
create_method_for( clazz.instance_type , method_name , args)
|
||||
end
|
||||
|
@ -1,18 +0,0 @@
|
||||
module Typed
|
||||
module ClassField
|
||||
|
||||
def on_ClassField statement
|
||||
#type , name , value = *statement
|
||||
|
||||
for_type = @type
|
||||
raise "no type" unless for_type
|
||||
index = for_type.variable_index(statement.name)
|
||||
raise "class field already defined:#{name} for class #{for_type}" if index
|
||||
|
||||
#FIXME should not hack into current type, but create a new
|
||||
for_type.send(:private_add_instance_variable, statement.name , statement.type)
|
||||
|
||||
return nil # statements don't reurn values, only expressions
|
||||
end
|
||||
end
|
||||
end
|
@ -49,14 +49,6 @@ module Typed
|
||||
w
|
||||
end
|
||||
|
||||
def on_class_field statement
|
||||
type , name = *statement
|
||||
w = Tree::ClassField.new()
|
||||
w.type = type
|
||||
w.name = name
|
||||
w
|
||||
end
|
||||
|
||||
def on_while_statement statement
|
||||
branch_type , condition , statements = *statement
|
||||
w = Tree::WhileStatement.new()
|
||||
|
Reference in New Issue
Block a user