check for redefining of methods and forbid

causing some test problems, but better that way (until it's done right off course)
This commit is contained in:
2019-09-24 21:20:12 +03:00
parent 3df54910cc
commit 1022390e0f
9 changed files with 45 additions and 24 deletions

View File

@ -6,9 +6,12 @@ module Vool
end
def self.load_builtin(loads)
return "class Space;def main(arg);return 0; end; end" if(loads == "Space.main")
raise "no preload #{loads}" unless builtin[loads]
clazz , meth = loads.split(".")
"class #{clazz} #{derive(clazz)}; #{Vool::Builtin.builtin[loads]};end;"
"class #{clazz} #{derive(clazz)}; #{builtin[loads]};end;"
end
def self.derive(clazz) #must get derived classes rigth, so no mismatch
case clazz
when "Integer"
@ -40,7 +43,6 @@ module Vool
"Word.put" => "def putstring(at); X.putstring;end",
"Word.set" => "def set_internal_byte(at, val); X.set_internal_byte;end",
"Word.get" => "def get_internal_byte(at); X.get_internal_byte;end",
"Space.main" => "def main(args);return nil;end",
}
end
def self.builtin_code

View File

@ -13,6 +13,10 @@ module Vool
# Must pass in the actual Parfait class (default nil is just to conform to api)
def to_parfait( clazz = nil )
raise "No class given to method #{name}" unless clazz
if( method = clazz.get_instance_method(name))
#FIXME , should check arg_type, and if the same, clear method and ok
raise "Redefining #{clazz.name}.#{name} not supported #{method}"
end
clazz.add_instance_method_for(name , make_arg_type , make_frame , body )
end