2014-08-28 17:27:04 +02:00
|
|
|
module Builtin
|
2014-06-03 13:49:02 +02:00
|
|
|
class Object
|
|
|
|
module ClassMethods
|
2015-05-04 22:03:52 +02:00
|
|
|
|
2015-05-30 13:49:10 +02:00
|
|
|
# main entry point, ie __init__ calls this
|
|
|
|
# defined here as empty, to be redefined
|
|
|
|
def main context
|
2015-05-31 17:34:18 +02:00
|
|
|
function = Virtual::CompiledMethodInfo.create_method(:Object,:main , [])
|
2015-05-30 13:49:10 +02:00
|
|
|
return function
|
2014-06-14 22:48:12 +02:00
|
|
|
end
|
2014-06-03 13:49:02 +02:00
|
|
|
|
2015-05-04 22:03:52 +02:00
|
|
|
# in ruby, how this goes is
|
2014-06-03 13:49:02 +02:00
|
|
|
# def _get_instance_variable var
|
|
|
|
# i = self.index_of(var)
|
|
|
|
# return at_index(i)
|
2015-05-04 22:03:52 +02:00
|
|
|
# end
|
2015-05-30 11:20:39 +02:00
|
|
|
# The at_index is just "below" the api, something we need but don't want to expose,
|
|
|
|
# so we can't code the above in ruby
|
2014-06-26 16:52:15 +02:00
|
|
|
def _get_instance_variable context , name = Virtual::Integer
|
2015-05-31 17:34:18 +02:00
|
|
|
get_function = Virtual::CompiledMethodInfo.create_method(:Object,:_get_instance_variable , [ Virtual::Reference ] )
|
2015-05-04 22:03:52 +02:00
|
|
|
return get_function
|
2014-06-07 16:59:44 +02:00
|
|
|
me = get_function.receiver
|
|
|
|
var_name = get_function.args.first
|
2014-06-03 13:49:02 +02:00
|
|
|
return_to = get_function.return_type
|
2014-06-24 18:34:36 +02:00
|
|
|
|
2015-06-01 07:40:17 +02:00
|
|
|
index_function = ::Virtual.machine.space.get_class_by_name(:Object).resolve_method(:index_of)
|
2014-09-09 17:03:13 +02:00
|
|
|
# get_function.push( [me] )
|
|
|
|
# index = get_function.call( index_function )
|
2015-05-04 22:03:52 +02:00
|
|
|
|
2014-06-24 18:34:36 +02:00
|
|
|
after_body = get_function.new_block("after_index")
|
2014-08-13 19:05:32 +02:00
|
|
|
get_function.current after_body
|
2015-05-04 22:03:52 +02:00
|
|
|
|
2014-09-09 17:03:13 +02:00
|
|
|
# get_function.pop([me])
|
|
|
|
# return_to.at_index( get_function , me , return_to )
|
2015-05-04 22:03:52 +02:00
|
|
|
|
2014-09-09 17:03:13 +02:00
|
|
|
# get_function.set_return return_to
|
2014-06-03 13:49:02 +02:00
|
|
|
return get_function
|
|
|
|
end
|
|
|
|
|
2014-06-26 16:52:15 +02:00
|
|
|
def _set_instance_variable(context , name = Virtual::Integer , value = Virtual::Integer )
|
2015-05-31 17:34:18 +02:00
|
|
|
set_function = Virtual::CompiledMethodInfo.create_method(:Object,:_set_instance_variable ,[Virtual::Reference ,Virtual::Reference] )
|
2014-07-12 20:59:17 +02:00
|
|
|
return set_function
|
|
|
|
receiver set_function
|
2014-06-24 11:23:58 +02:00
|
|
|
me = set_function.receiver
|
|
|
|
var_name = set_function.args.first
|
|
|
|
return_to = set_function.return_type
|
2015-05-16 11:54:11 +02:00
|
|
|
index_function = context.object_space.get_class_by_name(:Object).resolve_method(:index_of)
|
2014-06-24 11:23:58 +02:00
|
|
|
set_function.push( [me] )
|
|
|
|
set_function.call( index_function )
|
|
|
|
after_body = set_function.new_block("after_index")
|
2015-05-04 22:03:52 +02:00
|
|
|
|
2014-08-13 19:05:32 +02:00
|
|
|
set_function.current after_body
|
2014-06-24 11:23:58 +02:00
|
|
|
set_function.pop([me])
|
|
|
|
return_to.at_index( set_function , me , return_to )
|
|
|
|
set_function.set_return return_to
|
|
|
|
return set_function
|
2014-06-03 13:49:02 +02:00
|
|
|
end
|
2015-05-04 22:03:52 +02:00
|
|
|
|
2014-06-05 17:17:00 +02:00
|
|
|
def _get_singleton_method(context , name )
|
2014-06-03 13:49:02 +02:00
|
|
|
raise name
|
|
|
|
end
|
2014-06-05 17:17:00 +02:00
|
|
|
def _add_singleton_method(context, method)
|
2014-06-03 13:49:02 +02:00
|
|
|
raise "4"
|
|
|
|
end
|
2014-06-05 17:17:00 +02:00
|
|
|
def initialize(context)
|
2014-06-03 13:49:02 +02:00
|
|
|
raise "4"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
extend ClassMethods
|
|
|
|
end
|
|
|
|
end
|
2014-08-28 15:44:27 +02:00
|
|
|
require_relative "integer"
|
2015-05-13 15:17:10 +02:00
|
|
|
require_relative "word"
|
2014-08-28 15:44:27 +02:00
|
|
|
require_relative "array"
|
2014-09-10 20:35:52 +02:00
|
|
|
require_relative "kernel"
|