SlotLanguageExploration

This commit is contained in:
2019-10-04 21:06:22 +03:00
parent 901f7b0132
commit 9885841eb4
5 changed files with 69 additions and 5 deletions

View File

@ -0,0 +1,22 @@
# passed in? name and cache_entry
word! << name_
cache_entry! << cache_entry_
# local var assignment
callable_method << cache_entry.cached_type.methods
while_start_label
goto(exit_label) if( nil == callable_method)
goto(ok_label) if(callable_method.name == word)
callable_method = callable_method.next_callable
goto(while_start_label)
exit_label
MethodMissing.new(compiler.source_name , word.symbol).to_risc(compiler)
ok_label
cache_entry.cached_method == callable_method

View File

@ -16,12 +16,30 @@ module SlotLanguage
not_implemented(node)
end
def on_send(statement)
#puts statement
kids = statement.children.dup
receiver = process(kids.shift) || MessageSlot.new
name = kids.shift
raise "Kids #{kids}" unless kids.empty?
return label(name) if(name.to_s.end_with?("_label"))
SlotMaker.new( name , receiver )
end
def on_lvasgn expression
#puts expression
name = expression.children[0]
value = process(expression.children[1])
Sol::LocalAssignment.new(name,value)
end
def on_ivar expression
Sol::InstanceVariable.new(instance_name(expression.children.first))
end
private
def instance_name(sym)
sym.to_s[1 .. -1].to_sym
end
def label(name)
SlotMachine::Label.new(name.to_s , name)
end
end
end
require_relative "named_slot"

View File

@ -1,7 +1,8 @@
module SlotLanguage
class SlotMaker
attr_reader :name
def initialize(name , more)
@name = name
end
end
end