Class: Rubex::AST::Statement::CStructOrUnionDef
- Defined in:
- lib/rubex/ast/statement/c_struct_or_union_def.rb
Instance Attribute Summary collapse
-
#declarations ⇒ Object
readonly
Returns the value of attribute declarations.
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Base
Instance Method Summary collapse
- #analyse_statement(outer_scope, extern: false) ⇒ Object
- #generate_code(code, local_scope = nil) ⇒ Object
-
#initialize(kind, name, declarations, location) ⇒ CStructOrUnionDef
constructor
A new instance of CStructOrUnionDef.
- #rescan_declarations(_local_scope) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(kind, name, declarations, location) ⇒ CStructOrUnionDef
Returns a new instance of CStructOrUnionDef.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/rubex/ast/statement/c_struct_or_union_def.rb', line 7 def initialize(kind, name, declarations, location) super(location) @declarations = declarations if /struct/.match kind @kind = :struct elsif /union/.match kind @kind = :union end @name = name end |
Instance Attribute Details
#declarations ⇒ Object (readonly)
Returns the value of attribute declarations.
5 6 7 |
# File 'lib/rubex/ast/statement/c_struct_or_union_def.rb', line 5 def declarations @declarations end |
#entry ⇒ Object (readonly)
Returns the value of attribute entry.
5 6 7 |
# File 'lib/rubex/ast/statement/c_struct_or_union_def.rb', line 5 def entry @entry end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
5 6 7 |
# File 'lib/rubex/ast/statement/c_struct_or_union_def.rb', line 5 def kind @kind end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/rubex/ast/statement/c_struct_or_union_def.rb', line 5 def name @name end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
5 6 7 |
# File 'lib/rubex/ast/statement/c_struct_or_union_def.rb', line 5 def scope @scope end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/rubex/ast/statement/c_struct_or_union_def.rb', line 5 def type @type end |
Instance Method Details
#analyse_statement(outer_scope, extern: false) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rubex/ast/statement/c_struct_or_union_def.rb', line 18 def analyse_statement(outer_scope, extern: false) @scope = Rubex::SymbolTable::Scope::StructOrUnion.new( @name, outer_scope ) c_name = if extern @kind.to_s + " " + @name else Rubex::TYPE_PREFIX + @scope.klass_name + "_" + @name end @type = Rubex::DataType::CStructOrUnion.new(@kind, @name, c_name, @scope) @declarations.each do |decl| decl.analyse_statement @scope, extern: extern end Rubex::CUSTOM_TYPES[@name] = @type @entry = outer_scope.declare_sue(name: @name, c_name: c_name, type: @type, extern: extern) end |
#generate_code(code, local_scope = nil) ⇒ Object
38 |
# File 'lib/rubex/ast/statement/c_struct_or_union_def.rb', line 38 def generate_code(code, local_scope = nil); end |
#rescan_declarations(_local_scope) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/rubex/ast/statement/c_struct_or_union_def.rb', line 40 def rescan_declarations(_local_scope) @declarations.each do |decl| decl.respond_to?(:rescan_declarations) && decl.rescan_declarations(@scope) end end |