moved statements up one dir
This commit is contained in:
parent
7377522417
commit
63dd6d9039
@ -62,19 +62,19 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
require_relative "statements/assign_statement"
|
require_relative "assign_statement"
|
||||||
require_relative "statements/array_statement"
|
require_relative "array_statement"
|
||||||
require_relative "statements/basic_values"
|
require_relative "basic_values"
|
||||||
require_relative "statements/block_statement"
|
require_relative "block_statement"
|
||||||
require_relative "statements/class_statement"
|
require_relative "class_statement"
|
||||||
require_relative "statements/hash_statement"
|
require_relative "hash_statement"
|
||||||
require_relative "statements/if_statement"
|
require_relative "if_statement"
|
||||||
require_relative "statements/logical_statement"
|
require_relative "logical_statement"
|
||||||
require_relative "statements/local_assignment"
|
require_relative "local_assignment"
|
||||||
require_relative "statements/method_statement"
|
require_relative "method_statement"
|
||||||
require_relative "statements/return_statement"
|
require_relative "return_statement"
|
||||||
require_relative "statements/statements"
|
require_relative "statements"
|
||||||
require_relative "statements/send_statement"
|
require_relative "send_statement"
|
||||||
require_relative "statements/variables"
|
require_relative "variables"
|
||||||
require_relative "statements/while_statement"
|
require_relative "while_statement"
|
||||||
require_relative "statements/yield_statement"
|
require_relative "yield_statement"
|
||||||
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
Loading…
Reference in New Issue
Block a user