removing exceptions
This commit is contained in:
@ -62,4 +62,8 @@ module Ast
|
||||
value
|
||||
end
|
||||
end
|
||||
class AssignmentExpression < Expression
|
||||
def compile frame , method
|
||||
end
|
||||
end
|
||||
end
|
@ -1,7 +1,8 @@
|
||||
module Ast
|
||||
class IfExpression < Expression
|
||||
# attr_reader :cond, :if_true, :if_false
|
||||
def compile context
|
||||
def compile frame , method
|
||||
return nil
|
||||
f = context.function
|
||||
# to execute the logic as the if states it, the blocks are the other way around
|
||||
# so we can the jump over the else if true ,and the else joins unconditionally after the true_block
|
||||
|
@ -1,7 +1,10 @@
|
||||
module Ast
|
||||
class OperatorExpression < Expression
|
||||
# attr_reader :operator, :left, :right
|
||||
def compile context
|
||||
def compile frame , method
|
||||
nil
|
||||
end
|
||||
def scratch
|
||||
into = context.function
|
||||
puts "compiling operator #{to_s}"
|
||||
r_val = right.compile(context)
|
||||
|
@ -1,7 +1,10 @@
|
||||
module Ast
|
||||
class ReturnExpression < Expression
|
||||
# attr_reader :expression
|
||||
def compile context
|
||||
def compile frame ,method
|
||||
nil
|
||||
end
|
||||
def sc
|
||||
into = context.function
|
||||
puts "compiling return expression #{expression}, now return in return_regsiter"
|
||||
expression_value = expression.compile(context)
|
||||
|
@ -1,7 +1,10 @@
|
||||
module Ast
|
||||
class WhileExpression < Expression
|
||||
# attr_reader :condition, :body
|
||||
def compile context
|
||||
def compile frame , method
|
||||
nil
|
||||
end
|
||||
def old
|
||||
into = context.function
|
||||
ret = into.new_block "while_end"
|
||||
while_block = into.new_block "while_start"
|
||||
|
@ -15,6 +15,9 @@ module Virtual
|
||||
def attributes
|
||||
[:next]
|
||||
end
|
||||
def initialize nex = nil
|
||||
@next = nex
|
||||
end
|
||||
end
|
||||
|
||||
# the first instruction we need is to stop. Off course in a real machine this would be a syscall, but that is just
|
||||
|
@ -15,15 +15,15 @@ module Virtual
|
||||
Method.new(:main , [] , Virtual::SelfReference )
|
||||
end
|
||||
def attributes
|
||||
[:name , :args , :receiver , :start , :return_type]
|
||||
[:name , :args , :receiver , :return_type , :start]
|
||||
end
|
||||
def initialize name , args , receiver = Virtual::SelfReference.new , return_type = Virtual::Reference
|
||||
def initialize name , args , receiver = Virtual::SelfReference.new , return_type = Virtual::Reference , start = MethodEnter.new
|
||||
@name = name.to_sym
|
||||
@args = args
|
||||
@locals = []
|
||||
@receiver = receiver
|
||||
@return_type = return_type
|
||||
@start = MethodEnter.new
|
||||
@start = start
|
||||
@current = @start
|
||||
end
|
||||
attr_reader :name , :args , :receiver , :start
|
||||
|
Reference in New Issue
Block a user