lib/castaddon/node_adarwin.rb in bones-compiler-1.3.1 vs lib/castaddon/node_adarwin.rb in bones-compiler-1.6.0
- old
+ new
@@ -144,10 +144,14 @@
# Less than (<)
elsif less?
results << ['',simplify("#{expr1}")+'='+simplify("(#{expr2})-1")]
+ # Equal (==)
+ elsif equality?
+ results << ['','']#[simplify("#{expr1}"),simplify("(#{expr2})")]
+
# Unsupported conditions
else
raise_error("Unsupported if-condition: #{self.to_s}")
end
end
@@ -230,9 +234,22 @@
# This method retrieves the name of the array reference.
def get_array_name()
self.preorder do |node|
return node.expr.to_s if node.index? && !node.expr.index?
end
+ end
+
+ # This method retrieves all variable declarations
+ def get_var_declarations()
+ vars = []
+ self.preorder do |node|
+ if node.declaration?
+ node.declarators.each do |decl|
+ vars << decl.name
+ end
+ end
+ end
+ return vars
end
# This method retrieves the value from the current node. The value can be an
# integer (in case of a constant) or a string (in case of a variable).
def get_value()
\ No newline at end of file