2014-06-26 17:39:02 +02:00
|
|
|
module Virtual
|
2014-05-13 15:24:19 +02:00
|
|
|
|
2014-07-15 08:12:51 +02:00
|
|
|
class Constant < ::Virtual::Value
|
2014-05-13 15:24:19 +02:00
|
|
|
end
|
2014-07-15 08:31:25 +02:00
|
|
|
class TrueValue < Constant
|
|
|
|
end
|
|
|
|
class FalseValue < Constant
|
|
|
|
end
|
|
|
|
class NilValue < Constant
|
|
|
|
end
|
2014-05-13 15:24:19 +02:00
|
|
|
|
2014-06-07 16:59:44 +02:00
|
|
|
# another abstract "marker" class (so we can check for it)
|
2014-06-26 17:39:02 +02:00
|
|
|
# derived classes are Boot/Meta Class and StringConstant
|
2014-06-07 16:59:44 +02:00
|
|
|
class ObjectConstant < Constant
|
|
|
|
end
|
2014-05-13 15:24:19 +02:00
|
|
|
|
|
|
|
class IntegerConstant < Constant
|
2014-05-13 17:21:24 +02:00
|
|
|
def initialize int
|
2014-05-13 15:24:19 +02:00
|
|
|
@integer = int
|
|
|
|
end
|
|
|
|
attr_reader :integer
|
2014-07-14 20:28:21 +02:00
|
|
|
def type
|
|
|
|
Virtual::Integer
|
|
|
|
end
|
2014-05-13 15:24:19 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
# The name really says it all.
|
|
|
|
# The only interesting thing is storage.
|
|
|
|
# Currently string are stored "inline" , ie in the code segment.
|
|
|
|
# Mainly because that works an i aint no elf expert.
|
|
|
|
|
2014-06-07 16:59:44 +02:00
|
|
|
class StringConstant < ObjectConstant
|
2014-05-13 15:24:19 +02:00
|
|
|
def initialize str
|
2014-07-12 20:59:17 +02:00
|
|
|
@string = str
|
2014-05-13 15:24:19 +02:00
|
|
|
end
|
2014-08-19 21:54:28 +02:00
|
|
|
attr_reader :string
|
2014-08-20 16:14:52 +02:00
|
|
|
def type
|
|
|
|
Virtual::Reference
|
|
|
|
end
|
2014-05-19 14:44:12 +02:00
|
|
|
def result= value
|
|
|
|
class_for(MoveInstruction).new(value , self , :opcode => :mov)
|
2014-05-13 15:24:19 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|