remoe hash attributes (less magic) and make attributes on context explicit
This commit is contained in:
parent
36f237c633
commit
6b715bbb1b
@ -1,26 +0,0 @@
|
|||||||
# Make hash attributes to object attributes
|
|
||||||
|
|
||||||
module Support
|
|
||||||
module HashAttributes
|
|
||||||
# map any function call to an attribute if possible
|
|
||||||
def method_missing name , *args , &block
|
|
||||||
if args.length > 1 or block_given?
|
|
||||||
puts "NO -#{args.length} BLOCK #{block_given?}"
|
|
||||||
super
|
|
||||||
else
|
|
||||||
sname = name.to_s
|
|
||||||
if args.length == 1 #must be assignemnt for ir attr= val
|
|
||||||
if sname.include? "="
|
|
||||||
#puts "setting :#{name.chop}:#{args[0]}"
|
|
||||||
return @attributes[sname.chop.to_sym] = args[0]
|
|
||||||
else
|
|
||||||
super
|
|
||||||
end
|
|
||||||
else
|
|
||||||
#puts "getting :#{name}:#{@attributes[name.to_sym]}"
|
|
||||||
return @attributes[sname.to_sym]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,17 +1,16 @@
|
|||||||
require "support/hash_attributes"
|
|
||||||
module Vm
|
module Vm
|
||||||
|
|
||||||
#currently just holding the object_space in here so we can have global access
|
#currently just holding the object_space in here so we can have global access
|
||||||
class Context
|
class Context
|
||||||
# Make hash attributes to object attributes
|
|
||||||
include Support::HashAttributes
|
|
||||||
|
|
||||||
def initialize object_space
|
def initialize object_space
|
||||||
@attributes = {}
|
@object_space = object_space
|
||||||
@attributes[:object_space] = object_space
|
@locals = {}
|
||||||
end
|
end
|
||||||
attr_reader :attributes
|
attr_reader :attributes ,:object_space
|
||||||
attr_accessor :current_class
|
|
||||||
|
attr_accessor :current_class , :locals , :function
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user