add assignment and self
This commit is contained in:
parent
d62e996f7c
commit
27e4e9f501
@ -1,13 +1,11 @@
|
|||||||
module Vool
|
module Vool
|
||||||
class Assignment < Statement
|
class Assignment < Statement
|
||||||
attr_accessor :name , :value
|
attr_accessor :name , :value
|
||||||
def initialize(n = nil , v = nil )
|
def initialize(name , value )
|
||||||
@name , @value = n , v
|
@name , @value = name , value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
class LocalAssignment < Assignment
|
||||||
class FieldDef < Statement
|
|
||||||
attr_accessor :name , :type , :value
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -17,6 +17,8 @@ module Vool
|
|||||||
end
|
end
|
||||||
class NilStatement < Statement
|
class NilStatement < Statement
|
||||||
end
|
end
|
||||||
|
class SelfStatement < Statement
|
||||||
|
end
|
||||||
class StringStatement < Statement
|
class StringStatement < Statement
|
||||||
attr_accessor :value
|
attr_accessor :value
|
||||||
def initialize(value)
|
def initialize(value)
|
||||||
|
@ -86,7 +86,6 @@ module Vool
|
|||||||
|
|
||||||
#Variables
|
#Variables
|
||||||
def on_lvasgn expression
|
def on_lvasgn expression
|
||||||
puts "EXP #{expression}"
|
|
||||||
name = expression.children[0]
|
name = expression.children[0]
|
||||||
value = process(expression.children[1])
|
value = process(expression.children[1])
|
||||||
LocalAssignment.new(name,value)
|
LocalAssignment.new(name,value)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
module Vool
|
module Vool
|
||||||
class CallSite < Statement
|
class SendStatement < Statement
|
||||||
attr_accessor :name , :receiver , :arguments
|
attr_accessor :name , :receiver , :arguments
|
||||||
end
|
end
|
||||||
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 "helper"
|
||||||
require_relative "test_array_statement"
|
require_relative "test_array_statement"
|
||||||
|
require_relative "test_assignment_statement"
|
||||||
require_relative "test_basic_values"
|
require_relative "test_basic_values"
|
||||||
require_relative "test_class_statement"
|
require_relative "test_class_statement"
|
||||||
require_relative "test_hash_statement"
|
require_relative "test_hash_statement"
|
||||||
require_relative "test_method_statement"
|
require_relative "test_method_statement"
|
||||||
|
require_relative "test_send_statement"
|
||||||
|
require_relative "test_variables"
|
||||||
|
Loading…
Reference in New Issue
Block a user