diff --git a/lib/ruby.rb b/lib/ruby.rb new file mode 100644 index 00000000..34b45b7e --- /dev/null +++ b/lib/ruby.rb @@ -0,0 +1,28 @@ +require "parser/ruby22" +require "ast" + +AST::Node.class_eval do + def first + children.first + end +end + +require_relative "ruby/statement" +require_relative "ruby/statements" +require_relative "ruby/array_statement" +require_relative "ruby/block_statement" +require_relative "ruby/if_statement" +require_relative "ruby/normalizer" +require_relative "ruby/send_statement" +require_relative "ruby/assign_statement" +require_relative "ruby/class_statement" +require_relative "ruby/logical_statement" +require_relative "ruby/return_statement" +require_relative "ruby/while_statement" +require_relative "ruby/basic_values" +require_relative "ruby/hash_statement" +require_relative "ruby/method_statement" +require_relative "ruby/ruby_compiler" +require_relative "ruby/yield_statement" + +require_relative "ruby/ruby_compiler" diff --git a/lib/ruby/array_statement.rb b/lib/ruby/array_statement.rb new file mode 100644 index 00000000..ad82e02e --- /dev/null +++ b/lib/ruby/array_statement.rb @@ -0,0 +1,13 @@ +module Ruby + class ArrayStatement + attr_reader :values + + def initialize( values ) + @values = values + end + + def length + @values.length + end + end +end diff --git a/lib/ruby/assign_statement.rb b/lib/ruby/assign_statement.rb new file mode 100644 index 00000000..b03784e5 --- /dev/null +++ b/lib/ruby/assign_statement.rb @@ -0,0 +1,53 @@ +module Ruby + + class Assignment < Statement + attr_reader :name , :value + def initialize(name , value ) + @name , @value = name , value + end + + def normalize() + raise "not named left #{name.class}" unless name.is_a?(Symbol) + case value + when Named , Constant + return copy + when SendStatement + return normalize_send + else + raise "unsupported right #{value}" + end + end + + def copy(value = nil) + value ||= @value + self.class.new(name,value) + end + + def normalize_send + statements = value.normalize() + return copy( statements ) if statements.is_a?(SendStatement) + assign = statements.statements.pop + statements << copy(assign) + statements + end + + def chain_assign(assign , compiler) + return assign unless @value.is_a?(SendStatement) + @value.to_mom(compiler) << assign + end + + def to_s(depth = 0) + at_depth(depth , "#{@name} = #{@value}") + end + + end + + class IvarAssignment < Assignment + + def normalize() + super() + return IvarAssignment.new(@name , @value) + end + + end +end diff --git a/lib/ruby/basic_values.rb b/lib/ruby/basic_values.rb new file mode 100644 index 00000000..f4a73a66 --- /dev/null +++ b/lib/ruby/basic_values.rb @@ -0,0 +1,108 @@ +module Ruby + class Constant < Expression + #gobble it up + def each(&block) + end + end + + class IntegerConstant < Constant + attr_reader :value + def initialize(value) + @value = value + end + def slot_definition(compiler) + return Mom::SlotDefinition.new(Mom::IntegerConstant.new(@value) , []) + end + def ct_type + Parfait.object_space.get_type_by_class_name(:Integer) + end + def to_s + value.to_s + end + def each(&block) + end + end + class FloatConstant < Constant + attr_reader :value + def initialize(value) + @value = value + end + def ct_type + true + end + end + class TrueConstant < Constant + def ct_type + Parfait.object_space.get_type_by_class_name(:True) + end + def slot_definition(compiler) + return Mom::SlotDefinition.new(Parfait.object_space.true_object , []) + end + def to_s(depth = 0) + "true" + end + end + class FalseConstant < Constant + def ct_type + Parfait.object_space.get_type_by_class_name(:False) + end + def slot_definition(compiler) + return Mom::SlotDefinition.new(Parfait.object_space.false_object , []) + end + def to_s(depth = 0) + "false" + end + end + class NilConstant < Constant + def ct_type + Parfait.object_space.get_type_by_class_name(:Nil) + end + def slot_definition(compiler) + return Mom::SlotDefinition.new(Parfait.object_space.nil_object , []) + end + def to_s(depth = 0) + "nil" + end + end + class SelfExpression < Expression + attr_reader :my_type + def initialize(type = nil) + @my_type = type + end + def slot_definition(compiler) + @my_type = compiler.receiver_type + Mom::SlotDefinition.new(:message , [:receiver]) + end + def ct_type + @my_type + end + def to_s(depth = 0) + "self" + end + end + class SuperExpression < Statement + def to_s(depth = 0) + "super" + end + end + class StringConstant < Constant + attr_reader :value + def initialize(value) + @value = value + end + def slot_definition(compiler) + return Mom::SlotDefinition.new(Mom::StringConstant.new(@value),[]) + end + def ct_type + Parfait.object_space.get_type_by_class_name(:Word) + end + def to_s(depth = 0) + "'#{@value}'" + end + end + class SymbolConstant < StringConstant + def ct_type + Parfait.object_space.get_type_by_class_name(:Word) + end + end +end diff --git a/lib/ruby/block_statement.rb b/lib/ruby/block_statement.rb new file mode 100644 index 00000000..c73e1382 --- /dev/null +++ b/lib/ruby/block_statement.rb @@ -0,0 +1,17 @@ +module Vool + + class BlockStatement < Statement + attr_reader :args , :body , :clazz + + def initialize( args , body , something_really_else) + @args , @body = args , body + raise "no bod" unless @body + @clazz = clazz + end + + def normalize + BlockStatement.new( @args , @body.normalize) + end + + end +end diff --git a/lib/ruby/class_statement.rb b/lib/ruby/class_statement.rb new file mode 100644 index 00000000..aada50ac --- /dev/null +++ b/lib/ruby/class_statement.rb @@ -0,0 +1,28 @@ +module Ruby + class ClassStatement < Statement + attr_reader :name, :super_class_name , :body + + def initialize( name , supe , body) + @name , @super_class_name = name , supe + case body + when MethodStatement + @body = Statements.new([body]) + when Statements + @body = body + when nil + @body = Statements.new([]) + else + raise "what body #{body}" + end + end + + def normalize + meths = body.statements.collect{|meth| meth.normalize} + ClassStatement.new(@name , @super_class_name, Statements.new(meths) ) + end + + def to_s(depth = 0) + at_depth(depth , "class #{name}" , @body.to_s(depth + 1) , "end") + end + end +end diff --git a/lib/ruby/hash_statement.rb b/lib/ruby/hash_statement.rb new file mode 100644 index 00000000..361314ff --- /dev/null +++ b/lib/ruby/hash_statement.rb @@ -0,0 +1,17 @@ +module Ruby + class HashStatement + attr_reader :hash + + def initialize( ) + @hash = {} + end + + def add(key , value) + @hash[key] = value + end + + def length + @hash.length + end + end +end diff --git a/lib/ruby/if_statement.rb b/lib/ruby/if_statement.rb new file mode 100644 index 00000000..5ede89f1 --- /dev/null +++ b/lib/ruby/if_statement.rb @@ -0,0 +1,39 @@ +require_relative "normalizer" + +module Ruby + class IfStatement < Statement + include Normalizer + + attr_reader :condition , :if_true , :if_false + + def initialize( cond , if_true , if_false = nil) + @condition = cond + @if_true = if_true + @if_false = if_false + end + + def normalize + cond , rest = *normalize_name(@condition) + fals = @if_false ? @if_false.normalize : nil + me = IfStatement.new(cond , @if_true.normalize, fals) + return me unless rest + rest << me + rest + end + + def has_false? + @if_false != nil + end + + def has_true? + @if_true != nil + end + + def to_s(depth = 0) + parts = ["if (#{@condition})" , @body.to_s(depth + 1) ] + parts += ["else" , "@if_false.to_s(depth + 1)"] if(@false) + parts << "end" + at_depth(depth , *parts ) + end + end +end diff --git a/lib/ruby/logical_statement.rb b/lib/ruby/logical_statement.rb new file mode 100644 index 00000000..77a6badb --- /dev/null +++ b/lib/ruby/logical_statement.rb @@ -0,0 +1,16 @@ +module Ruby + # Logical Statements are guaranteed to return boolean + # either :and or :or, which may be written as && and || + class LogicalStatement < Statement + attr_reader :name , :left , :right + + def initialize(name , left , right) + @name , @left , @right = name , left , right + end + + def to_s(depth = 0) + at_depth(depth , "#{left} #{name} #{right}") + end + + end +end diff --git a/lib/ruby/method_statement.rb b/lib/ruby/method_statement.rb new file mode 100644 index 00000000..234b9d0b --- /dev/null +++ b/lib/ruby/method_statement.rb @@ -0,0 +1,27 @@ +module Ruby + class MethodStatement < Statement + attr_reader :name, :args , :body , :clazz + + def initialize( name , args , body , clazz = nil) + @name , @args , @body = name , args , body + raise "no bod" unless @body + @clazz = clazz + end + + + def normalize + MethodStatement.new( @name , @args , @body.normalize) + end + + def has_yield? + each{|statement| return true if statement.is_a?(YieldStatement)} + return false + end + + def to_s(depth = 0) + arg_str = @args.collect{|a| a.to_s}.join(', ') + at_depth(depth , "def #{name}(#{arg_str})" , @body.to_s(depth + 1) , "end") + end + + end +end diff --git a/lib/ruby/normalizer.rb b/lib/ruby/normalizer.rb new file mode 100644 index 00000000..5476d70f --- /dev/null +++ b/lib/ruby/normalizer.rb @@ -0,0 +1,22 @@ +module Ruby + module Normalizer + # given a something, determine if it is a Name + # + # Return a Name, and a possible rest that has a hoisted part of the statement + # + # eg if( @var % 5) is not normalized + # but if(tmp_123) is with tmp_123 = @var % 5 hoisted above the if + # + # also constants count, though they may not be so useful in ifs, but returns + def normalize_name( condition ) + if( condition.is_a?(ScopeStatement) and condition.single?) + condition = condition.first + end + return [condition] if condition.is_a?(Named) or condition.is_a?(Constant) + condition = condition.normalize + local = "tmp_#{object_id}".to_sym + assign = Statements.new [LocalAssignment.new( local , condition)] + [LocalVariable.new(local) , assign] + end + end +end diff --git a/lib/ruby/return_statement.rb b/lib/ruby/return_statement.rb new file mode 100644 index 00000000..9cf7de8d --- /dev/null +++ b/lib/ruby/return_statement.rb @@ -0,0 +1,23 @@ +module Ruby + class ReturnStatement < Statement + include Normalizer + + attr_reader :return_value + + def initialize(value) + @return_value = value + end + + def normalize + val , rest = *normalize_name(@return_value) + me = ReturnStatement.new(val) + return me unless rest + rest << me + rest + end + + def to_s(depth = 0) + at_depth(depth , "return #{@return_value.to_s}") + end + end +end diff --git a/lib/rubyx/ruby_compiler.rb b/lib/ruby/ruby_compiler.rb similarity index 69% rename from lib/rubyx/ruby_compiler.rb rename to lib/ruby/ruby_compiler.rb index 61554154..f9427962 100644 --- a/lib/rubyx/ruby_compiler.rb +++ b/lib/ruby/ruby_compiler.rb @@ -1,12 +1,13 @@ - -module RubyX - # This RubyCompiler compiles incoming ruby (string) into vools internal representation - # with the help of the parser gem. The parser outputs an abstract ast (nodes) +module Ruby + # This RubyCompiler compiles incoming ruby (string) into a typed + # version of theast, with the help of the parser gem. + # The parser outputs an abstract ast (nodes) # that get transformed into concrete, specific classes. # # As a second step, it extracts classes, methods, ivars and locals. # - # The next step is then to normalize the code and then finally to compile + # The next step is then to go to the vool level, which is + # simpler, and then finally to compile # to the next level down, MOM (Minimal Object Machine) class RubyCompiler < AST::Processor include AST::Sexp @@ -23,13 +24,13 @@ module RubyX def on_class( statement ) name , sup , body = *statement - Vool::ClassStatement.new( get_name(name) , get_name(sup) , process(body) ) + ClassStatement.new( get_name(name) , get_name(sup) , process(body) ) end def on_def( statement ) name , args , body = *statement arg_array = process_all( args ) - Vool::MethodStatement.new( name , arg_array , process(body) ) + MethodStatement.new( name , arg_array , process(body) ) end def on_arg( arg ) @@ -40,13 +41,13 @@ module RubyX sendd = process(block_node.children[0]) args = process(block_node.children[1]) body = process(block_node.children[2]) - sendd.add_block Vool::BlockStatement.new(args , body) + sendd.add_block BlockStatement.new(args , body) sendd end def on_yield(node) args = process_all(node.children) - Vool::YieldStatement.new(args) + YieldStatement.new(args) end def on_args(args) @@ -55,31 +56,31 @@ module RubyX #basic Values def on_self exp - Vool::SelfExpression.new + SelfExpression.new end def on_nil expression - Vool::NilConstant.new + NilConstant.new end def on_int expression - Vool::IntegerConstant.new(expression.children.first) + IntegerConstant.new(expression.children.first) end def on_float expression - Vool::FloatConstant.new(expression.children.first) + FloatConstant.new(expression.children.first) end def on_true expression - Vool::TrueConstant.new + TrueConstant.new end def on_false expression - Vool::FalseConstant.new + FalseConstant.new end def on_str expression - Vool::StringConstant.new(expression.children.first) + StringConstant.new(expression.children.first) end alias :on_string :on_str @@ -89,7 +90,7 @@ module RubyX alias :on_xstr :on_dstr def on_sym expression - Vool::SymbolConstant.new(expression.children.first) + SymbolConstant.new(expression.children.first) end alias :on_string :on_str @@ -97,17 +98,17 @@ module RubyX raise "Not implemented dynamix symbols (with interpolation)" end def on_kwbegin statement - Vool::ScopeStatement.new process_all( statement.children ) + ScopeStatement.new process_all( statement.children ) end alias :on_begin :on_kwbegin # Array + Hashes def on_array expression - Vool::ArrayStatement.new expression.children.collect{ |elem| process(elem) } + ArrayStatement.new expression.children.collect{ |elem| process(elem) } end def on_hash expression - hash = Vool::HashStatement.new + hash = HashStatement.new expression.children.each do |elem| raise "Hash error, hash contains non pair: #{elem.type}" if elem.type != :pair hash.add( process(elem.children[0]) , process(elem.children[1]) ) @@ -117,15 +118,15 @@ module RubyX #Variables def on_lvar expression - Vool::LocalVariable.new(expression.children.first) + LocalVariable.new(expression.children.first) end def on_ivar expression - Vool::InstanceVariable.new(instance_name(expression.children.first)) + InstanceVariable.new(instance_name(expression.children.first)) end def on_cvar expression - Vool::ClassVariable.new(expression.children.first.to_s[2 .. -1].to_sym) + ClassVariable.new(expression.children.first.to_s[2 .. -1].to_sym) end def on_const expression @@ -133,20 +134,20 @@ module RubyX if scope raise "Only unscoped Names implemented #{scope}" unless scope.type == :cbase end - Vool::ModuleName.new(expression.children[1]) + ModuleName.new(expression.children[1]) end # Assignements def on_lvasgn expression name = expression.children[0] value = process(expression.children[1]) - Vool::LocalAssignment.new(name,value) + LocalAssignment.new(name,value) end def on_ivasgn expression name = expression.children[0] value = process(expression.children[1]) - Vool::IvarAssignment.new(instance_name(name),value) + IvarAssignment.new(instance_name(name),value) end def on_op_asgn(expression) @@ -161,52 +162,52 @@ module RubyX def on_return statement return_value = process(statement.children.first) - Vool::ReturnStatement.new( return_value ) + ReturnStatement.new( return_value ) end def on_while statement condition , statements = *statement - Vool::WhileStatement.new( process(condition) , process(statements)) + WhileStatement.new( process(condition) , process(statements)) end def on_if statement condition , if_true , if_false = *statement if_true = process(if_true) if_false = process(if_false) - Vool::IfStatement.new( process(condition) , if_true , if_false ) + IfStatement.new( process(condition) , if_true , if_false ) end def on_send statement kids = statement.children.dup - receiver = process(kids.shift) || Vool::SelfExpression.new + receiver = process(kids.shift) || SelfExpression.new name = kids.shift arguments = process_all(kids) - Vool::SendStatement.new( name , receiver , arguments ) + SendStatement.new( name , receiver , arguments ) end def on_and expression name = expression.type left = process(expression.children[0]) right = process( expression.children[1] ) - Vool::LogicalStatement.new( name , left , right) + LogicalStatement.new( name , left , right) end alias :on_or :on_and # this is a call to super without args (z = zero arity) def on_zsuper exp - Vool::SendStatement.new( nil , Vool::SuperExpression.new , nil) + SendStatement.new( nil , SuperExpression.new , nil) end # this is a call to super with args and # same name as current method, which is set later def on_super( statement ) arguments = process_all(statement.children) - Vool::SendStatement.new( nil , Vool::SuperExpression.new , arguments) + SendStatement.new( nil , SuperExpression.new , arguments) end def on_assignment statement name , value = *statement - w = Vool::Assignment.new() + w = Assignment.new() w.name = process name w.value = process(value) w diff --git a/lib/ruby/send_statement.rb b/lib/ruby/send_statement.rb new file mode 100644 index 00000000..b97ae46e --- /dev/null +++ b/lib/ruby/send_statement.rb @@ -0,0 +1,39 @@ +module Ruby + + class SendStatement < Statement + attr_reader :name , :receiver , :arguments + + def initialize(name , receiver , arguments ) + @name , @receiver , @arguments = name , receiver , arguments + @arguments ||= [] + end + + def normalize + statements = Statements.new([]) + arguments = [] + @arguments.each_with_index do |arg , index | + normalize_arg(arg , arguments , statements) + end + if statements.empty? + return SendStatement.new(@name, @receiver , @arguments) + else + statements << SendStatement.new(@name, @receiver , arguments) + return statements + end + end + + def normalize_arg(arg , arguments , statements) + if arg.respond_to?(:slot_definition) and !arg.is_a?(SendStatement) + arguments << arg + return + end + assign = LocalAssignment.new( "tmp_#{arg.object_id}".to_sym, arg) + statements << assign + arguments << LocalVariable.new(assign.name) + end + + def to_s + "#{receiver}.#{name}(#{arguments.join(', ')})" + end + end +end diff --git a/lib/ruby/statement.rb b/lib/ruby/statement.rb new file mode 100644 index 00000000..de21ccbc --- /dev/null +++ b/lib/ruby/statement.rb @@ -0,0 +1,25 @@ +module Ruby + + # Base class for all statements in the tree. Derived classes correspond to known language + # constructs + # + # Compilers or compiler passes are written by implementing methods. + # + class Statement + + def at_depth(depth , *strings) + prefix = " " * 2 * depth + strings.collect{|str| prefix + str}.join("\n") + end + + end + + class Expression + + def normalize + raise "should not be normalized #{self}" + end + + end + +end diff --git a/lib/ruby/statements.rb b/lib/ruby/statements.rb new file mode 100644 index 00000000..5a0e6c15 --- /dev/null +++ b/lib/ruby/statements.rb @@ -0,0 +1,55 @@ +module Ruby + class Statements < Statement + attr_reader :statements + def initialize(statements) + @statements = statements + end + + def empty? + @statements.empty? + end + def single? + @statements.length == 1 + end + def first + @statements.first + end + def last + @statements.last + end + def length + @statements.length + end + def [](i) + @statements[i] + end + def <<(o) + @statements << o + self + end + + # create mom instructions + def to_mom( compiler ) + raise "Empty list ? #{statements.length}" if empty? + stats = @statements.dup + flat = stats.shift.to_mom(compiler) + while( nekst = stats.shift ) + flat.append nekst.to_mom(compiler) + end + flat + end + + def each(&block) + block.call(self) + @statements.each{|a| a.each(&block)} + end + + def to_s(depth = 0) + at_depth(depth , *@statements.collect{|st| st.to_s(depth)}) + end + + end + + class ScopeStatement < Statements + end +end diff --git a/lib/ruby/while_statement.rb b/lib/ruby/while_statement.rb new file mode 100644 index 00000000..31f75b36 --- /dev/null +++ b/lib/ruby/while_statement.rb @@ -0,0 +1,24 @@ +require_relative "normalizer" + +module Ruby + class WhileStatement < Statement + include Normalizer + attr_reader :condition , :body , :hoisted + + def initialize( condition , body , hoisted = nil) + @hoisted = hoisted + @condition = condition + @body = body + end + + def normalize + cond , rest = *normalize_name(@condition) + WhileStatement.new(cond , @body.normalize , rest) + end + + def to_s(depth = 0) + at_depth(depth , "while (#{@condition})" , @body.to_s(depth + 1) , "end" ) + end + + end +end diff --git a/lib/ruby/yield_statement.rb b/lib/ruby/yield_statement.rb new file mode 100644 index 00000000..d8b44e6f --- /dev/null +++ b/lib/ruby/yield_statement.rb @@ -0,0 +1,39 @@ +module Ruby + + class YieldStatement < Statement + attr_reader :arguments + + def initialize(arguments ) + @arguments = arguments + @arguments ||= [] + end + + def normalize + statements = Statements.new([]) + arguments = [] + @arguments.each_with_index do |arg , index | + normalize_arg(arg , arguments , statements) + end + if statements.empty? + return YieldStatement.new(@name, @receiver , @arguments) + else + statements << YieldStatement.new(@name, @receiver , arguments) + return statements + end + end + + def normalize_arg(arg , arguments , statements) + if arg.respond_to?(:slot_definition) and !arg.is_a?(YieldStatement) + arguments << arg + return + end + assign = LocalAssignment.new( "tmp_#{arg.object_id}".to_sym, arg) + statements << assign + arguments << LocalVariable.new(assign.name) + end + + def to_s + "#{receiver}.#{name}(#{arguments.join(', ')})" + end + end +end diff --git a/test/ruby/helper.rb b/test/ruby/helper.rb new file mode 100644 index 00000000..6ce5e69a --- /dev/null +++ b/test/ruby/helper.rb @@ -0,0 +1,17 @@ +require_relative "../helper" + +module Ruby + module RubyTests + def setup + Parfait.boot! + end + def compile(input) + RubyCompiler.compile(input) + end + + def ruby_to_vool(input) + RubyXCompiler.new(input).ruby_to_vool + end + + end +end diff --git a/test/rubyx/ruby_compiler/test_array_statement.rb b/test/ruby/test_array_statement.rb similarity index 97% rename from test/rubyx/ruby_compiler/test_array_statement.rb rename to test/ruby/test_array_statement.rb index 4951ba77..964b2998 100644 --- a/test/rubyx/ruby_compiler/test_array_statement.rb +++ b/test/ruby/test_array_statement.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby class TestArrayX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_basic_values.rb b/test/ruby/test_basic_values.rb similarity index 99% rename from test/rubyx/ruby_compiler/test_basic_values.rb rename to test/ruby/test_basic_values.rb index 78d1a108..90531250 100644 --- a/test/rubyx/ruby_compiler/test_basic_values.rb +++ b/test/ruby/test_basic_values.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby class TestBasicValuesX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_block_statement.rb b/test/ruby/test_block_statement.rb similarity index 98% rename from test/rubyx/ruby_compiler/test_block_statement.rb rename to test/ruby/test_block_statement.rb index 612afa3a..072d1eb1 100644 --- a/test/rubyx/ruby_compiler/test_block_statement.rb +++ b/test/ruby/test_block_statement.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby class TestBlockStatementX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_class_statement.rb b/test/ruby/test_class_statement.rb similarity index 98% rename from test/rubyx/ruby_compiler/test_class_statement.rb rename to test/ruby/test_class_statement.rb index f4e61672..839f5171 100644 --- a/test/rubyx/ruby_compiler/test_class_statement.rb +++ b/test/ruby/test_class_statement.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby class TestEmptyClassStatementX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_hash_statement.rb b/test/ruby/test_hash_statement.rb similarity index 98% rename from test/rubyx/ruby_compiler/test_hash_statement.rb rename to test/ruby/test_hash_statement.rb index 841e5935..cb1837cc 100644 --- a/test/rubyx/ruby_compiler/test_hash_statement.rb +++ b/test/ruby/test_hash_statement.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby class HashArrayX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_if_statement.rb b/test/ruby/test_if_statement.rb similarity index 99% rename from test/rubyx/ruby_compiler/test_if_statement.rb rename to test/ruby/test_if_statement.rb index cea64c66..25346813 100644 --- a/test/rubyx/ruby_compiler/test_if_statement.rb +++ b/test/ruby/test_if_statement.rb @@ -1,6 +1,6 @@ require_relative 'helper' -module Vool +module Ruby class TestIfStatementX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_ivar_assignment.rb b/test/ruby/test_ivar_assignment.rb similarity index 98% rename from test/rubyx/ruby_compiler/test_ivar_assignment.rb rename to test/ruby/test_ivar_assignment.rb index ddabfab7..e5597e6c 100644 --- a/test/rubyx/ruby_compiler/test_ivar_assignment.rb +++ b/test/ruby/test_ivar_assignment.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby class TestIvarAssignmentX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_local_assignment.rb b/test/ruby/test_local_assignment.rb similarity index 98% rename from test/rubyx/ruby_compiler/test_local_assignment.rb rename to test/ruby/test_local_assignment.rb index dea8fa9c..ba361ada 100644 --- a/test/rubyx/ruby_compiler/test_local_assignment.rb +++ b/test/ruby/test_local_assignment.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby class TestLocalAssignmentX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_logical_statement.rb b/test/ruby/test_logical_statement.rb similarity index 98% rename from test/rubyx/ruby_compiler/test_logical_statement.rb rename to test/ruby/test_logical_statement.rb index 860ff52d..6d865f67 100644 --- a/test/rubyx/ruby_compiler/test_logical_statement.rb +++ b/test/ruby/test_logical_statement.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby class TestLogicalX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_method_statement.rb b/test/ruby/test_method_statement.rb similarity index 98% rename from test/rubyx/ruby_compiler/test_method_statement.rb rename to test/ruby/test_method_statement.rb index 528b95ad..90e507ef 100644 --- a/test/rubyx/ruby_compiler/test_method_statement.rb +++ b/test/ruby/test_method_statement.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby class TestMethodStatementX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_op_assignment.rb b/test/ruby/test_op_assignment.rb similarity index 98% rename from test/rubyx/ruby_compiler/test_op_assignment.rb rename to test/ruby/test_op_assignment.rb index c888d473..9502da2f 100644 --- a/test/rubyx/ruby_compiler/test_op_assignment.rb +++ b/test/ruby/test_op_assignment.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby module OpAss def test_local_name assert_equal :foo , @lst.name diff --git a/test/rubyx/ruby_compiler/test_return_statement.rb b/test/ruby/test_return_statement.rb similarity index 97% rename from test/rubyx/ruby_compiler/test_return_statement.rb rename to test/ruby/test_return_statement.rb index a7916c67..ce77601a 100644 --- a/test/rubyx/ruby_compiler/test_return_statement.rb +++ b/test/ruby/test_return_statement.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby class TestReturnStatementX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_send_statement.rb b/test/ruby/test_send_statement.rb similarity index 99% rename from test/rubyx/ruby_compiler/test_send_statement.rb rename to test/ruby/test_send_statement.rb index 26e3433b..9f02c851 100644 --- a/test/rubyx/ruby_compiler/test_send_statement.rb +++ b/test/ruby/test_send_statement.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby class TestSendX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_variables.rb b/test/ruby/test_variables.rb similarity index 99% rename from test/rubyx/ruby_compiler/test_variables.rb rename to test/ruby/test_variables.rb index f81c9cfb..4dffc1e7 100644 --- a/test/rubyx/ruby_compiler/test_variables.rb +++ b/test/ruby/test_variables.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby class TestVariablesX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_while_statement.rb b/test/ruby/test_while_statement.rb similarity index 98% rename from test/rubyx/ruby_compiler/test_while_statement.rb rename to test/ruby/test_while_statement.rb index cc2995ba..9b4da818 100644 --- a/test/rubyx/ruby_compiler/test_while_statement.rb +++ b/test/ruby/test_while_statement.rb @@ -1,6 +1,6 @@ require_relative 'helper' -module Vool +module Ruby class TestWhileStatementX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/test_yield_statement.rb b/test/ruby/test_yield_statement.rb similarity index 98% rename from test/rubyx/ruby_compiler/test_yield_statement.rb rename to test/ruby/test_yield_statement.rb index 6a969199..3b45d8e1 100644 --- a/test/rubyx/ruby_compiler/test_yield_statement.rb +++ b/test/ruby/test_yield_statement.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Vool +module Ruby class TestYieldStatementX < MiniTest::Test include RubyTests diff --git a/test/rubyx/ruby_compiler/helper.rb b/test/rubyx/ruby_compiler/helper.rb deleted file mode 100644 index 2a02bafc..00000000 --- a/test/rubyx/ruby_compiler/helper.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative "../../helper" - -module Vool - module RubyTests - def compile(input) - RubyX::RubyCompiler.compile(input) - end - end -end