fix true false and nil constant
going from mom to parfait basics in place, more ripples to fix
This commit is contained in:
@ -29,16 +29,25 @@ module Mom
|
||||
end
|
||||
end
|
||||
class TrueConstant < Constant
|
||||
def to_parfait(compiler)
|
||||
Parfait.object_space.true_object
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:TrueClass).instance_type
|
||||
end
|
||||
end
|
||||
class FalseConstant < Constant
|
||||
def to_parfait(compiler)
|
||||
Parfait.object_space.false_object
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:FalseClass).instance_type
|
||||
end
|
||||
end
|
||||
class NilConstant < Constant
|
||||
def to_parfait(compiler)
|
||||
Parfait.object_space.nil_object
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:NilClass).instance_type
|
||||
end
|
||||
@ -48,6 +57,11 @@ module Mom
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def to_parfait(compiler)
|
||||
value = Parfait.new_word(@value)
|
||||
compiler.add_constant(value)
|
||||
value
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_class_by_name(:Word).instance_type
|
||||
end
|
||||
|
@ -29,10 +29,19 @@ module Parfait
|
||||
end
|
||||
|
||||
# adding other base classes in here for now:
|
||||
class FalseClass
|
||||
class FalseClass < Data2
|
||||
#FIXME: this is "just" for compilation
|
||||
def initialize
|
||||
end
|
||||
end
|
||||
class TrusClass
|
||||
class TrueClass < Data2
|
||||
#FIXME: this is "just" for compilation
|
||||
def initialize
|
||||
end
|
||||
end
|
||||
class NilClass
|
||||
class NilClass < Data2
|
||||
#FIXME: this is "just" for compilation
|
||||
def initialize
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -44,9 +44,13 @@ module Parfait
|
||||
@classes.each do |name , cl|
|
||||
add_type(cl.instance_type)
|
||||
end
|
||||
@true_object = Parfait::TrueClass.new
|
||||
@false_object = Parfait::FalseClass.new
|
||||
@nil_object = Parfait::NilClass.new
|
||||
end
|
||||
|
||||
attr_reader :classes , :first_message
|
||||
attr_reader :classes , :first_message , :first_integer
|
||||
attr_reader :true_object , :false_object , :nil_object
|
||||
|
||||
def each_type
|
||||
@types.values.each do |type|
|
||||
|
@ -140,8 +140,9 @@ module Risc
|
||||
Kernel: {}, #fix, kernel is a class, but should be a module
|
||||
BinaryCode: {next: :BinaryCode} ,
|
||||
Space: {classes: :Dictionary , types: :Dictionary ,
|
||||
first_message: :Message , single_true: :TrueClass,
|
||||
single_false: :FalseClass , single_nil: :NilClass},
|
||||
first_message: :Message , first_integer: :Integer ,
|
||||
true_object: :TrueClass,
|
||||
false_object: :FalseClass , nil_object: :NilClass},
|
||||
NamedList: {},
|
||||
Type: {names: :List , types: :List ,
|
||||
object_class: :Class, methods: :List } ,
|
||||
|
Reference in New Issue
Block a user