add a kenrnel array class with function stubs
This commit is contained in:
parent
da3cd69a5c
commit
9dd37a74df
@ -1,4 +1,5 @@
|
|||||||
require_relative "integer"
|
require_relative "integer"
|
||||||
require_relative "string"
|
require_relative "string"
|
||||||
|
require_relative "array"
|
||||||
require_relative "system"
|
require_relative "system"
|
||||||
require_relative "object"
|
require_relative "object"
|
||||||
|
19
lib/kernel/array.rb
Normal file
19
lib/kernel/array.rb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
module Salama
|
||||||
|
class Array
|
||||||
|
module ClassMethods
|
||||||
|
def get context , index = Virtual::Integer
|
||||||
|
get_function = Virtual::CompiledMethod.new(:get , [ Virtual::Integer] , Virtual::Integer , Virtual::Integer )
|
||||||
|
return get_function
|
||||||
|
end
|
||||||
|
def set context , index = Virtual::Integer , object = Virtual::Reference
|
||||||
|
set_function = Virtual::CompiledMethod.new(:set , [Virtual::Integer, Virtual::Reference] )
|
||||||
|
return set_function
|
||||||
|
end
|
||||||
|
def push context , object = Virtual::Reference
|
||||||
|
push_function = Virtual::CompiledMethod.new(:push , [Virtual::Reference] )
|
||||||
|
return push_function
|
||||||
|
end
|
||||||
|
end
|
||||||
|
extend ClassMethods
|
||||||
|
end
|
||||||
|
end
|
@ -2,15 +2,8 @@
|
|||||||
# instead it is parsed by salama to define part of the program that runs
|
# instead it is parsed by salama to define part of the program that runs
|
||||||
|
|
||||||
class Array < BaseObject
|
class Array < BaseObject
|
||||||
def initialize size
|
#many basic array functions can not be defined in ruby, such as
|
||||||
|
# get/set/length/add/delete
|
||||||
|
# so they must be defined as CompiledMethods in Salama::Kernel
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def at(index)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def set(index , value)
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@ -82,6 +82,10 @@ module Virtual
|
|||||||
#puts "Boot String::#{f}"
|
#puts "Boot String::#{f}"
|
||||||
obj.add_instance_method Salama::String.send(f , @context)
|
obj.add_instance_method Salama::String.send(f , @context)
|
||||||
end
|
end
|
||||||
|
obj = get_or_create_class :Array
|
||||||
|
[:get , :set , :push].each do |f|
|
||||||
|
obj.add_instance_method Salama::Array.send(f , @context)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Objects are data and get assembled after functions
|
# Objects are data and get assembled after functions
|
||||||
|
Loading…
Reference in New Issue
Block a user