update reader and implement singletons

This commit is contained in:
Torsten Ruger 2014-07-01 15:57:13 +03:00
parent 94d1140686
commit 7045a4b256
7 changed files with 48 additions and 5 deletions

View File

@ -7,7 +7,7 @@ GIT
GIT GIT
remote: https://github.com/ruby-in-ruby/crystal-reader.git remote: https://github.com/ruby-in-ruby/crystal-reader.git
revision: 3a56ae1a8d96845bbb80f760626c8203d57cb1c3 revision: bc8697c733113b19863df632b546c7eab2b429c0
specs: specs:
crystal-reader (0.1.0) crystal-reader (0.1.0)

View File

@ -9,6 +9,22 @@ module Ast
end end
end end
class TrueExpression
def compile frame
Virtual::TrueValue.new
end
end
class FalseExpression
def compile frame
Virtual::FalseValue.new
end
end
class NilExpression
def compile frame
Virtual::NilValue.new
end
end
class NameExpression < Expression class NameExpression < Expression
# attr_reader :name # attr_reader :name

View File

@ -1,7 +1,6 @@
module Virtual module Virtual
class Constant < ::Virtual::Object class Constant < ::Virtual::Object
end end
# another abstract "marker" class (so we can check for it) # another abstract "marker" class (so we can check for it)

View File

@ -1,6 +1,6 @@
module Virtual module Virtual
class Mystery < Value class Mystery < Value
def initilize def initialize
end end
def as type def as type
@ -8,4 +8,11 @@ module Virtual
end end
end end
class TrueValue < Value
end
class FalseValue < Value
end
class NilValue < Value
end
end end

View File

@ -6,6 +6,12 @@ module Virtual
# Integer and (Object) References are the main derived classes, but float will come and ... # Integer and (Object) References are the main derived classes, but float will come and ...
# The Mystery Value has unknown type and has only casting methods. So it must be cast to be useful. # The Mystery Value has unknown type and has only casting methods. So it must be cast to be useful.
class Value class Value
def == other
other.class == self.class
end
def inspect
self.class.name + ".new()"
end
def type def type
self.class self.class
end end

View File

@ -1,2 +1 @@
require_relative "fragments/test_all" require_relative "fragments/test_all"
require_relative "test_intel"

View File

@ -10,6 +10,22 @@ class TestBasic < MiniTest::Test
check check
end end
def test_true
@string_input = 'true '
@output = [Virtual::TrueValue.new()]
check
end
def test_false
@string_input = 'false '
@output = [Virtual::FalseValue.new()]
check
end
def test_nil
@string_input = 'nil '
@output = [Virtual::NilValue.new()]
check
end
def test_name def test_name
@string_input = 'foo ' @string_input = 'foo '
@output = [nil] @output = [nil]