Class: AdLint::Cc1::Environment

Inherits:
Object
  • Object
show all
Includes:
EnumeratorTableMediator, FunctionTableMediator, MemoryPoolMediator, TypeTableMediator, VariableTableMediator
Defined in:
lib/adlint/cc1/environ.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FunctionTableMediator

#declare_explicit_function, #declare_implicit_function, #define_anonymous_function, #define_explicit_function

Methods included from VariableTableMediator

#create_tmpvar, #local_variables

Methods included from MemoryPoolMediator

#pointee_of

Constructor Details

#initialize(type_tbl) ⇒ Environment

Returns a new instance of Environment.



48
49
50
51
52
53
54
55
56
# 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

Instance Attribute Details

#current_scopeObject (readonly)

Returns the value of attribute current_scope.



63
64
65
# File 'lib/adlint/cc1/environ.rb', line 63

def current_scope
  @current_scope
end

#enumerator_tableObject (readonly)

Returns the value of attribute enumerator_table.



62
63
64
# File 'lib/adlint/cc1/environ.rb', line 62

def enumerator_table
  @enumerator_table
end

#function_tableObject (readonly)

Returns the value of attribute function_table.



61
62
63
# File 'lib/adlint/cc1/environ.rb', line 61

def function_table
  @function_table
end

#memory_poolObject (readonly)

Returns the value of attribute memory_pool.



59
60
61
# File 'lib/adlint/cc1/environ.rb', line 59

def memory_pool
  @memory_pool
end

#type_tableObject (readonly)

Returns the value of attribute type_table.



58
59
60
# File 'lib/adlint/cc1/environ.rb', line 58

def type_table
  @type_table
end

#variable_tableObject (readonly)

Returns the value of attribute variable_table.



60
61
62
# File 'lib/adlint/cc1/environ.rb', line 60

def variable_table
  @variable_table
end

Instance Method Details

#begin_versioningObject



131
132
133
# File 'lib/adlint/cc1/environ.rb', line 131

def begin_versioning
  @variable_table.begin_variables_value_versioning
end

#current_branchObject



110
111
112
113
114
115
116
# 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_groupObject



90
91
92
# 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) ⇒ Object



135
136
137
138
139
140
# 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) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
# 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) ⇒ Object



83
84
85
86
87
88
# 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_scopeObject



71
72
73
74
75
# 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_groupObject



123
124
125
# File 'lib/adlint/cc1/environ.rb', line 123

def enter_versioning_group
  @variable_table.enter_variables_value_versioning_group
end

#leave_branchObject



118
119
120
121
# File 'lib/adlint/cc1/environ.rb', line 118

def leave_branch
  # NOTE: Don't delete current branch!
  @branch_depth -= 1
end

#leave_branch_groupObject



94
95
96
# File 'lib/adlint/cc1/environ.rb', line 94

def leave_branch_group
  @branch_groups.delete(@branch_depth)
end

#leave_scopeObject



77
78
79
80
81
# 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) ⇒ Object



127
128
129
# File 'lib/adlint/cc1/environ.rb', line 127

def leave_versioning_group(raise_complement)
  @variable_table.leave_variables_value_versioning_group(raise_complement)
end

#resetObject



65
66
67
68
69
# File 'lib/adlint/cc1/environ.rb', line 65

def reset
  @current_scope = GlobalScope.new
  @branch_depth  = 0
  @branch_groups = {}
end