Some docs and to_s testing
somewhat code_climate inspired
This commit is contained in:
@ -1,16 +1,18 @@
|
||||
module Vool
|
||||
#Marker class for different constants
|
||||
class Constant < Expression
|
||||
#gobble it up
|
||||
def each(&block)
|
||||
end
|
||||
end
|
||||
|
||||
# An integer at the vool level
|
||||
class IntegerConstant < Constant
|
||||
attr_reader :value
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def slot_definition(compiler)
|
||||
def slot_definition(_)
|
||||
return Mom::SlotDefinition.new(Mom::IntegerConstant.new(@value) , [])
|
||||
end
|
||||
def ct_type
|
||||
@ -22,6 +24,7 @@ module Vool
|
||||
def each(&block)
|
||||
end
|
||||
end
|
||||
# An float at the vool level
|
||||
class FloatConstant < Constant
|
||||
attr_reader :value
|
||||
def initialize(value)
|
||||
@ -30,40 +33,48 @@ module Vool
|
||||
def ct_type
|
||||
true
|
||||
end
|
||||
def to_s
|
||||
value.to_s
|
||||
end
|
||||
end
|
||||
# True at the vool level
|
||||
class TrueConstant < Constant
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:True)
|
||||
end
|
||||
def slot_definition(compiler)
|
||||
def slot_definition(_)
|
||||
return Mom::SlotDefinition.new(Parfait.object_space.true_object , [])
|
||||
end
|
||||
def to_s(depth = 0)
|
||||
"true"
|
||||
end
|
||||
end
|
||||
# False at the vool level
|
||||
class FalseConstant < Constant
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:False)
|
||||
end
|
||||
def slot_definition(compiler)
|
||||
def slot_definition(_)
|
||||
return Mom::SlotDefinition.new(Parfait.object_space.false_object , [])
|
||||
end
|
||||
def to_s(depth = 0)
|
||||
"false"
|
||||
end
|
||||
end
|
||||
# Nil at the vool level
|
||||
class NilConstant < Constant
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:Nil)
|
||||
end
|
||||
def slot_definition(compiler)
|
||||
def slot_definition(_)
|
||||
return Mom::SlotDefinition.new(Parfait.object_space.nil_object , [])
|
||||
end
|
||||
def to_s(depth = 0)
|
||||
"nil"
|
||||
end
|
||||
end
|
||||
|
||||
# Self at the vool level
|
||||
class SelfExpression < Expression
|
||||
attr_reader :my_type
|
||||
def initialize(type = nil)
|
||||
@ -90,7 +101,7 @@ module Vool
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def slot_definition(compiler)
|
||||
def slot_definition(_)
|
||||
return Mom::SlotDefinition.new(Mom::StringConstant.new(@value),[])
|
||||
end
|
||||
def ct_type
|
||||
|
@ -10,7 +10,7 @@ module Vool
|
||||
|
||||
# When used as right hand side, this tells what data to move to get the result into
|
||||
# a varaible. It is (off course) the return value of the message
|
||||
def slot_definition(compiler)
|
||||
def slot_definition(_)
|
||||
Mom::SlotDefinition.new(:message ,[ :return_value])
|
||||
end
|
||||
|
||||
|
@ -21,7 +21,7 @@ module Vool
|
||||
|
||||
class InstanceVariable < Expression
|
||||
include Named
|
||||
def slot_definition(compiler)
|
||||
def slot_definition(_)
|
||||
Mom::SlotDefinition.new(:message , [ :receiver , @name] )
|
||||
end
|
||||
# used to collect type information
|
||||
|
Reference in New Issue
Block a user