class Bpl::AST::Program
Attributes
source_file[RW]
Public Instance Methods
fresh_var(prefix,type)
click to toggle source
# File lib/bpl/ast/program.rb, line 19 def fresh_var(prefix,type) taken = global_variables.map{|d| d.names}.flatten name = prefix unless taken.include?(prefix) name ||= (0..Float::INFINITY).each do |i| break "#{prefix}_#{i}" unless taken.include?("#{prefix}_#{i}") end self << decl = bpl("var #{name}: #{type};") return StorageIdentifier.new(name: name, declaration: decl) end
global_variables()
click to toggle source
# File lib/bpl/ast/program.rb, line 15 def global_variables each_child.select{|d| d.is_a?(VariableDeclaration)} end
show() { |d| ... }
click to toggle source
# File lib/bpl/ast/program.rb, line 11 def show @declarations.map{|d| yield d} * "\n" + "\n" end