2014-08-28 18:27:04 +03:00
|
|
|
module Builtin
|
2014-06-03 14:49:02 +03:00
|
|
|
class Object
|
|
|
|
module ClassMethods
|
|
|
|
|
|
|
|
# return the index of the variable. Now "normal" code can't really do anything with that, but
|
|
|
|
# set/get instance variable use it.
|
|
|
|
# This is just a placeholder, as we code this in ruby, but the instance methods need the definition before.
|
2014-06-26 17:52:15 +03:00
|
|
|
def index_of context , name = Virtual::Integer
|
2014-08-28 08:10:33 +03:00
|
|
|
index_function = Virtual::CompiledMethod.new(:index_of , Virtual::Reference , [Virtual::Reference] , Virtual::Integer )
|
2014-06-03 14:49:02 +03:00
|
|
|
return index_function
|
|
|
|
end
|
|
|
|
|
2014-06-14 23:48:12 +03:00
|
|
|
def self.layout
|
2014-07-12 21:59:17 +03:00
|
|
|
layout_function = Virtual::Function.new(:layout , [ ] , Virtual::Reference , Virtual::Reference )
|
2014-06-14 23:48:12 +03:00
|
|
|
layout_function.at_index 2
|
|
|
|
layout_function
|
|
|
|
end
|
2014-06-03 14:49:02 +03:00
|
|
|
|
|
|
|
# in ruby, how this goes is
|
|
|
|
# def _get_instance_variable var
|
|
|
|
# i = self.index_of(var)
|
|
|
|
# return at_index(i)
|
|
|
|
# end
|
2014-06-24 19:34:36 +03: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 17:52:15 +03:00
|
|
|
def _get_instance_variable context , name = Virtual::Integer
|
2014-08-28 08:10:33 +03:00
|
|
|
get_function = Virtual::CompiledMethod.new(:_get_instance_variable , [ Virtual::Reference ] , Virtual::Reference ,Virtual::Mystery )
|
2014-09-09 18:03:13 +03:00
|
|
|
# return get_function
|
2014-06-07 17:59:44 +03:00
|
|
|
me = get_function.receiver
|
|
|
|
var_name = get_function.args.first
|
2014-06-03 14:49:02 +03:00
|
|
|
return_to = get_function.return_type
|
2014-06-24 19:34:36 +03:00
|
|
|
|
2014-09-09 18:03:13 +03:00
|
|
|
index_function = ::Virtual::BootSpace.space.get_or_create_class(:Object).resolve_method(:index_of)
|
|
|
|
# get_function.push( [me] )
|
|
|
|
# index = get_function.call( index_function )
|
2014-06-10 23:57:56 +03:00
|
|
|
|
2014-06-24 19:34:36 +03:00
|
|
|
after_body = get_function.new_block("after_index")
|
2014-08-13 20:05:32 +03:00
|
|
|
get_function.current after_body
|
2014-06-24 19:34:36 +03:00
|
|
|
|
2014-09-09 18:03:13 +03:00
|
|
|
# get_function.pop([me])
|
|
|
|
# return_to.at_index( get_function , me , return_to )
|
2014-06-24 19:34:36 +03:00
|
|
|
|
2014-09-09 18:03:13 +03:00
|
|
|
# get_function.set_return return_to
|
2014-06-03 14:49:02 +03:00
|
|
|
return get_function
|
|
|
|
end
|
|
|
|
|
2014-06-26 17:52:15 +03:00
|
|
|
def _set_instance_variable(context , name = Virtual::Integer , value = Virtual::Integer )
|
2014-08-28 08:10:33 +03:00
|
|
|
set_function = Virtual::CompiledMethod.new(:_set_instance_variable ,[Virtual::Reference ,Virtual::Reference], Virtual::Reference ,Virtual::Mystery )
|
2014-07-12 21:59:17 +03:00
|
|
|
return set_function
|
|
|
|
receiver set_function
|
2014-06-24 12:23:58 +03:00
|
|
|
me = set_function.receiver
|
|
|
|
var_name = set_function.args.first
|
|
|
|
return_to = set_function.return_type
|
2014-09-09 18:03:13 +03:00
|
|
|
index_function = context.object_space.get_or_create_class(:Object).resolve_method(:index_of)
|
2014-06-24 12:23:58 +03:00
|
|
|
set_function.push( [me] )
|
|
|
|
set_function.call( index_function )
|
|
|
|
after_body = set_function.new_block("after_index")
|
|
|
|
|
2014-08-13 20:05:32 +03:00
|
|
|
set_function.current after_body
|
2014-06-24 12:23:58 +03: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 14:49:02 +03:00
|
|
|
end
|
|
|
|
|
2014-06-05 18:17:00 +03:00
|
|
|
def _get_singleton_method(context , name )
|
2014-06-03 14:49:02 +03:00
|
|
|
raise name
|
|
|
|
end
|
2014-06-05 18:17:00 +03:00
|
|
|
def _add_singleton_method(context, method)
|
2014-06-03 14:49:02 +03:00
|
|
|
raise "4"
|
|
|
|
end
|
2014-06-05 18:17:00 +03:00
|
|
|
def initialize(context)
|
2014-06-03 14:49:02 +03:00
|
|
|
raise "4"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
extend ClassMethods
|
|
|
|
end
|
|
|
|
end
|
2014-08-28 16:44:27 +03:00
|
|
|
require_relative "integer"
|
|
|
|
require_relative "string"
|
|
|
|
require_relative "array"
|
2014-09-10 21:35:52 +03:00
|
|
|
require_relative "kernel"
|