add assignment and self
This commit is contained in:
parent
d62e996f7c
commit
27e4e9f501
@ -1,13 +1,11 @@
|
||||
module Vool
|
||||
class Assignment < Statement
|
||||
attr_accessor :name , :value
|
||||
def initialize(n = nil , v = nil )
|
||||
@name , @value = n , v
|
||||
def initialize(name , value )
|
||||
@name , @value = name , value
|
||||
end
|
||||
end
|
||||
|
||||
class FieldDef < Statement
|
||||
attr_accessor :name , :type , :value
|
||||
class LocalAssignment < Assignment
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
@ -17,6 +17,8 @@ module Vool
|
||||
end
|
||||
class NilStatement < Statement
|
||||
end
|
||||
class SelfStatement < Statement
|
||||
end
|
||||
class StringStatement < Statement
|
||||
attr_accessor :value
|
||||
def initialize(value)
|
||||
|
@ -86,7 +86,6 @@ module Vool
|
||||
|
||||
#Variables
|
||||
def on_lvasgn expression
|
||||
puts "EXP #{expression}"
|
||||
name = expression.children[0]
|
||||
value = process(expression.children[1])
|
||||
LocalAssignment.new(name,value)
|
||||
|
@ -1,5 +1,5 @@
|
||||
module Vool
|
||||
class CallSite < Statement
|
||||
class SendStatement < Statement
|
||||
attr_accessor :name , :receiver , :arguments
|
||||
end
|
||||
end
|
16
test/vool/test_assignment_statement.rb
Normal file
16
test/vool/test_assignment_statement.rb
Normal file
@ -0,0 +1,16 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Vool
|
||||
class TestAssignment < MiniTest::Test
|
||||
|
||||
def test_local
|
||||
lst = Compiler.compile( "foo = bar")
|
||||
assert_equal LocalAssignment , lst.class
|
||||
end
|
||||
def test_local_name
|
||||
lst = Compiler.compile( "foo = bar")
|
||||
assert_equal :foo , lst.name
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,6 +1,9 @@
|
||||
require_relative "helper"
|
||||
require_relative "test_array_statement"
|
||||
require_relative "test_assignment_statement"
|
||||
require_relative "test_basic_values"
|
||||
require_relative "test_class_statement"
|
||||
require_relative "test_hash_statement"
|
||||
require_relative "test_method_statement"
|
||||
require_relative "test_send_statement"
|
||||
require_relative "test_variables"
|
||||
|
Loading…
Reference in New Issue
Block a user