From 63dd6d9039659d89ae23803ee86b09d2e4a957d6 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Fri, 29 Jun 2018 22:46:00 +0300 Subject: [PATCH] moved statements up one dir --- lib/vool/{statements => }/array_statement.rb | 0 lib/vool/{statements => }/assign_statement.rb | 0 lib/vool/{statements => }/block_statement.rb | 0 lib/vool/{statements => }/class_statement.rb | 0 lib/vool/{statements => }/hash_statement.rb | 0 lib/vool/{statements => }/if_statement.rb | 0 .../{statements => }/logical_statement.rb | 0 lib/vool/{statements => }/method_statement.rb | 0 lib/vool/{statements => }/return_statement.rb | 0 lib/vool/{statements => }/send_statement.rb | 0 lib/vool/statement.rb | 32 +++---- lib/vool/{statements => }/statements.rb | 0 lib/vool/statements/basic_values.rb | 93 ------------------- lib/vool/statements/local_assignment.rb | 17 ---- lib/vool/statements/normalizer.rb | 22 ----- lib/vool/statements/variables.rb | 41 -------- lib/vool/{statements => }/while_statement.rb | 0 lib/vool/{statements => }/yield_statement.rb | 0 18 files changed, 16 insertions(+), 189 deletions(-) rename lib/vool/{statements => }/array_statement.rb (100%) rename lib/vool/{statements => }/assign_statement.rb (100%) rename lib/vool/{statements => }/block_statement.rb (100%) rename lib/vool/{statements => }/class_statement.rb (100%) rename lib/vool/{statements => }/hash_statement.rb (100%) rename lib/vool/{statements => }/if_statement.rb (100%) rename lib/vool/{statements => }/logical_statement.rb (100%) rename lib/vool/{statements => }/method_statement.rb (100%) rename lib/vool/{statements => }/return_statement.rb (100%) rename lib/vool/{statements => }/send_statement.rb (100%) rename lib/vool/{statements => }/statements.rb (100%) delete mode 100644 lib/vool/statements/basic_values.rb delete mode 100644 lib/vool/statements/local_assignment.rb delete mode 100644 lib/vool/statements/normalizer.rb delete mode 100644 lib/vool/statements/variables.rb rename lib/vool/{statements => }/while_statement.rb (100%) rename lib/vool/{statements => }/yield_statement.rb (100%) diff --git a/lib/vool/statements/array_statement.rb b/lib/vool/array_statement.rb similarity index 100% rename from lib/vool/statements/array_statement.rb rename to lib/vool/array_statement.rb diff --git a/lib/vool/statements/assign_statement.rb b/lib/vool/assign_statement.rb similarity index 100% rename from lib/vool/statements/assign_statement.rb rename to lib/vool/assign_statement.rb diff --git a/lib/vool/statements/block_statement.rb b/lib/vool/block_statement.rb similarity index 100% rename from lib/vool/statements/block_statement.rb rename to lib/vool/block_statement.rb diff --git a/lib/vool/statements/class_statement.rb b/lib/vool/class_statement.rb similarity index 100% rename from lib/vool/statements/class_statement.rb rename to lib/vool/class_statement.rb diff --git a/lib/vool/statements/hash_statement.rb b/lib/vool/hash_statement.rb similarity index 100% rename from lib/vool/statements/hash_statement.rb rename to lib/vool/hash_statement.rb diff --git a/lib/vool/statements/if_statement.rb b/lib/vool/if_statement.rb similarity index 100% rename from lib/vool/statements/if_statement.rb rename to lib/vool/if_statement.rb diff --git a/lib/vool/statements/logical_statement.rb b/lib/vool/logical_statement.rb similarity index 100% rename from lib/vool/statements/logical_statement.rb rename to lib/vool/logical_statement.rb diff --git a/lib/vool/statements/method_statement.rb b/lib/vool/method_statement.rb similarity index 100% rename from lib/vool/statements/method_statement.rb rename to lib/vool/method_statement.rb diff --git a/lib/vool/statements/return_statement.rb b/lib/vool/return_statement.rb similarity index 100% rename from lib/vool/statements/return_statement.rb rename to lib/vool/return_statement.rb diff --git a/lib/vool/statements/send_statement.rb b/lib/vool/send_statement.rb similarity index 100% rename from lib/vool/statements/send_statement.rb rename to lib/vool/send_statement.rb diff --git a/lib/vool/statement.rb b/lib/vool/statement.rb index e182092c..fc1067b6 100644 --- a/lib/vool/statement.rb +++ b/lib/vool/statement.rb @@ -62,19 +62,19 @@ module Vool end -require_relative "statements/assign_statement" -require_relative "statements/array_statement" -require_relative "statements/basic_values" -require_relative "statements/block_statement" -require_relative "statements/class_statement" -require_relative "statements/hash_statement" -require_relative "statements/if_statement" -require_relative "statements/logical_statement" -require_relative "statements/local_assignment" -require_relative "statements/method_statement" -require_relative "statements/return_statement" -require_relative "statements/statements" -require_relative "statements/send_statement" -require_relative "statements/variables" -require_relative "statements/while_statement" -require_relative "statements/yield_statement" +require_relative "assign_statement" +require_relative "array_statement" +require_relative "basic_values" +require_relative "block_statement" +require_relative "class_statement" +require_relative "hash_statement" +require_relative "if_statement" +require_relative "logical_statement" +require_relative "local_assignment" +require_relative "method_statement" +require_relative "return_statement" +require_relative "statements" +require_relative "send_statement" +require_relative "variables" +require_relative "while_statement" +require_relative "yield_statement" diff --git a/lib/vool/statements/statements.rb b/lib/vool/statements.rb similarity index 100% rename from lib/vool/statements/statements.rb rename to lib/vool/statements.rb diff --git a/lib/vool/statements/basic_values.rb b/lib/vool/statements/basic_values.rb deleted file mode 100644 index 7d2876d1..00000000 --- a/lib/vool/statements/basic_values.rb +++ /dev/null @@ -1,93 +0,0 @@ -module Vool - 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(method) - return Mom::SlotDefinition.new(Mom::IntegerConstant.new(@value) , []) - end - def ct_type - Parfait.object_space.get_class_by_name(:Integer).instance_type - 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_class_by_name(:True).instance_type - end - def slot_definition(method) - return Mom::SlotDefinition.new(Parfait.object_space.true_object , []) - end - end - class FalseConstant < Constant - def ct_type - Parfait.object_space.get_class_by_name(:False).instance_type - end - def slot_definition(method) - return Mom::SlotDefinition.new(Parfait.object_space.false_object , []) - end - end - class NilConstant < Constant - def ct_type - Parfait.object_space.get_class_by_name(:Nil).instance_type - end - def slot_definition(method) - return Mom::SlotDefinition.new(Parfait.object_space.nil_object , []) - end - end - class SelfExpression < Expression - attr_reader :my_type - def initialize(type = nil) - @my_type = type - end - def slot_definition(in_method) - @my_type = in_method.for_type - Mom::SlotDefinition.new(:message , [:receiver]) - end - def ct_type - @my_type - end - def to_s - "self" - end - end - class SuperExpression < Statement - end - class StringConstant < Constant - attr_reader :value - def initialize(value) - @value = value - end - def slot_definition(method) - return Mom::SlotDefinition.new(Mom::StringConstant.new(@value),[]) - end - def ct_type - Parfait.object_space.get_class_by_name(:Word).instance_type - end - end - class SymbolConstant < StringConstant - def ct_type - Parfait.object_space.get_class_by_name(:Word).instance_type - end - end -end diff --git a/lib/vool/statements/local_assignment.rb b/lib/vool/statements/local_assignment.rb deleted file mode 100644 index b71f33f5..00000000 --- a/lib/vool/statements/local_assignment.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Vool - - class LocalAssignment < Assignment - - def to_mom( method ) - if method.arguments_type.variable_index(@name) - type = :arguments - else - type = :frame - end - to = Mom::SlotDefinition.new(:message ,[ type , @name]) - from = @value.slot_definition(method) - return chain_assign( Mom::SlotLoad.new(to,from) , method) - end - end - -end diff --git a/lib/vool/statements/normalizer.rb b/lib/vool/statements/normalizer.rb deleted file mode 100644 index 7574731e..00000000 --- a/lib/vool/statements/normalizer.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Vool - 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/vool/statements/variables.rb b/lib/vool/statements/variables.rb deleted file mode 100644 index 8f7a5ff7..00000000 --- a/lib/vool/statements/variables.rb +++ /dev/null @@ -1,41 +0,0 @@ -module Vool - module Named - attr_reader :name - def initialize name - @name = name - end - def each(&block) - end - end - - class LocalVariable < Expression - include Named - def slot_definition(method) - if method.arguments_type.variable_index(@name) - type = :arguments - else - type = :frame - end - Mom::SlotDefinition.new(:message , [type , @name]) - end - end - - class InstanceVariable < Expression - include Named - def slot_definition(method) - Mom::SlotDefinition.new(:message , [ :receiver , @name] ) - end - # used to collect type information - def add_ivar( array ) - array << @name - end - end - - class ClassVariable < Expression - include Named - end - - class ModuleName < Expression - include Named - end -end diff --git a/lib/vool/statements/while_statement.rb b/lib/vool/while_statement.rb similarity index 100% rename from lib/vool/statements/while_statement.rb rename to lib/vool/while_statement.rb diff --git a/lib/vool/statements/yield_statement.rb b/lib/vool/yield_statement.rb similarity index 100% rename from lib/vool/statements/yield_statement.rb rename to lib/vool/yield_statement.rb