adds a mom version of basic values
This commit is contained in:
55
lib/mom/basic_values.rb
Normal file
55
lib/mom/basic_values.rb
Normal file
@ -0,0 +1,55 @@
|
||||
module Mom
|
||||
# just name scoping the same stuff to mom
|
||||
# so we know we are on the way down, keeping our layers seperated
|
||||
# and we can put constant adding into the to_risc methods (instead of on vool classes)
|
||||
class Constant
|
||||
end
|
||||
|
||||
class IntegerConstant < Constant
|
||||
attr_reader :value
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:Integer).instance_type
|
||||
end
|
||||
end
|
||||
class FloatConstant < Constant
|
||||
attr_reader :value
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def ct_type
|
||||
true
|
||||
end
|
||||
end
|
||||
class TrueConstant < Constant
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:True).instance_type
|
||||
end
|
||||
end
|
||||
class FalseConstant < Constant
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:False).instance_type
|
||||
end
|
||||
end
|
||||
class NilConstant < Constant
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:Nil).instance_type
|
||||
end
|
||||
end
|
||||
class StringConstant < Constant
|
||||
attr_reader :value
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:Word).instance_type
|
||||
end
|
||||
end
|
||||
class SymbolConstant < String
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:Word).instance_type
|
||||
end
|
||||
end
|
||||
end
|
@ -19,6 +19,7 @@ module Mom
|
||||
end
|
||||
end
|
||||
|
||||
require_relative "basic_values"
|
||||
require_relative "simple_call"
|
||||
require_relative "dynamic_call"
|
||||
require_relative "truth_check"
|
||||
|
@ -30,7 +30,8 @@ module Mom
|
||||
def initialize(left , right)
|
||||
left = SlotDefinition.new(left.shift , left) if left.is_a? Array
|
||||
@left , @right = left , right
|
||||
raise "right not SlotDefinition, #{left}" unless left.is_a? SlotDefinition
|
||||
raise "left not SlotDefinition, #{left}" unless left.is_a? SlotDefinition
|
||||
# raise "right not Mom, #{right.to_rxf}" unless right.class.name.include?("Mom")
|
||||
end
|
||||
end
|
||||
|
||||
@ -44,7 +45,7 @@ module Mom
|
||||
|
||||
def initialize(left , right)
|
||||
super
|
||||
raise "right not constant, #{right}" unless right.is_a? Vool::ConstantStatement
|
||||
raise "right not constant, #{right}" unless right.is_a? Mom::Constant
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user