class AdLint::Cc1::Environment

Attributes

current_scope[R]
enumerator_table[R]
function_table[R]
memory_pool[R]
type_table[R]
variable_table[R]

Public Class Methods

new(type_tbl) click to toggle source
# File lib/adlint/cc1/environ.rb, line 48
def initialize(type_tbl)
  @type_table       = type_tbl
  @memory_pool      = MemoryPool.new
  @variable_table   = VariableTable.new(@memory_pool)
  @function_table   = FunctionTable.new(@memory_pool)
  @enumerator_table = EnumeratorTable.new
  install_builtin_functions
  reset
end

Public Instance Methods

begin_versioning() click to toggle source
# File lib/adlint/cc1/environ.rb, line 131
def begin_versioning
  @variable_table.begin_variables_value_versioning
end
current_branch() click to toggle source
# File lib/adlint/cc1/environ.rb, line 110
def current_branch
  if cur_group = current_branch_group
    cur_group.current_branch
  else
    nil
  end
end
current_branch_group() click to toggle source
# File lib/adlint/cc1/environ.rb, line 90
def current_branch_group
  @branch_groups[@branch_depth]
end
end_versioning(thin_this_version, with_rollback = thin_this_version) click to toggle source
# File lib/adlint/cc1/environ.rb, line 135
def end_versioning(thin_this_version, with_rollback = thin_this_version)
  if thin_this_version
    @variable_table.thin_latest_variables_value_version!(with_rollback)
  end
  @variable_table.end_variables_value_versioning
end
enter_branch(*opts) click to toggle source
# File lib/adlint/cc1/environ.rb, line 98
def enter_branch(*opts)
  @branch_depth += 1

  if group = current_branch_group
    group.add_options(*opts)
    group.create_trailing_branch(*opts)
  else
    group = enter_branch_group(*opts)
    group.create_first_branch(*opts)
  end
end
enter_branch_group(*opts) click to toggle source
# File lib/adlint/cc1/environ.rb, line 83
def enter_branch_group(*opts)
  if trunk_group = @branch_groups[@branch_depth - 1]
    trunk = trunk_group.current_branch
  end
  @branch_groups[@branch_depth] = BranchGroup.new(self, trunk, *opts)
end
enter_scope() click to toggle source
# File lib/adlint/cc1/environ.rb, line 71
def enter_scope
  @current_scope = current_scope.inner_scope
  @variable_table.enter_scope
  @function_table.enter_scope
end
enter_versioning_group() click to toggle source
# File lib/adlint/cc1/environ.rb, line 123
def enter_versioning_group
  @variable_table.enter_variables_value_versioning_group
end
leave_branch() click to toggle source
# File lib/adlint/cc1/environ.rb, line 118
def leave_branch
  # NOTE: Don't delete current branch!
  @branch_depth -= 1
end
leave_branch_group() click to toggle source
# File lib/adlint/cc1/environ.rb, line 94
def leave_branch_group
  @branch_groups.delete(@branch_depth)
end
leave_scope() click to toggle source
# File lib/adlint/cc1/environ.rb, line 77
def leave_scope
  @current_scope = current_scope.outer_scope
  @variable_table.leave_scope
  @function_table.leave_scope
end
leave_versioning_group(raise_complement) click to toggle source
# File lib/adlint/cc1/environ.rb, line 127
def leave_versioning_group(raise_complement)
  @variable_table.leave_variables_value_versioning_group(raise_complement)
end
reset() click to toggle source
# File lib/adlint/cc1/environ.rb, line 65
def reset
  @current_scope = GlobalScope.new
  @branch_depth  = 0
  @branch_groups = {}
end

Private Instance Methods

install_builtin_functions() click to toggle source
# File lib/adlint/cc1/environ.rb, line 143
def install_builtin_functions
  @function_table.define(InspectFunction.new(@type_table))
  @function_table.define(EvalFunction.new(@type_table))
end