Class: Rubex::AST::TopStatement::Klass
- Inherits:
-
Object
- Object
- Rubex::AST::TopStatement::Klass
- Includes:
- Helpers::Writers
- Defined in:
- lib/rubex/ast/top_statement/klass.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#ancestor ⇒ Object
readonly
Returns the value of attribute ancestor.
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#scope ⇒ Object
readonly
Stores the scope of the class.
-
#statements ⇒ Object
readonly
Returns the value of attribute statements.
Instance Method Summary collapse
- #analyse_statement(local_scope, attach_klass: false) ⇒ Object
- #generate_code(code) ⇒ Object
-
#initialize(name, ancestor, statements) ⇒ Klass
constructor
Name of the class.
- #rescan_declarations(_local_scope) ⇒ Object
Methods included from Helpers::Writers
#declare_carrays, #declare_ruby_objects, #declare_temps, #declare_types, #declare_vars, #sue_footer, #sue_header, #write_char_2_ruby_str_code, #write_char_2_ruby_str_header, #write_usability_functions_code, #write_usability_functions_header, #write_usability_macros
Constructor Details
#initialize(name, ancestor, statements) ⇒ Klass
Name of the class. Ancestor can be Scope::Klass or String object
depending on whether invoker is another higher level scope or
the parser. Statements are the statements inside the class.
20 21 22 23 24 25 |
# File 'lib/rubex/ast/top_statement/klass.rb', line 20 def initialize(name, ancestor, statements) @name = name @ancestor = ancestor @statements = statements @ancestor = 'Object' if @ancestor.nil? end |
Instance Attribute Details
#ancestor ⇒ Object (readonly)
Returns the value of attribute ancestor.
11 12 13 |
# File 'lib/rubex/ast/top_statement/klass.rb', line 11 def ancestor @ancestor end |
#entry ⇒ Object (readonly)
Returns the value of attribute entry.
15 16 17 |
# File 'lib/rubex/ast/top_statement/klass.rb', line 15 def entry @entry end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/rubex/ast/top_statement/klass.rb', line 9 def name @name end |
#scope ⇒ Object (readonly)
Stores the scope of the class. Rubex::SymbolTable::Scope::Klass.
7 8 9 |
# File 'lib/rubex/ast/top_statement/klass.rb', line 7 def scope @scope end |
#statements ⇒ Object (readonly)
Returns the value of attribute statements.
13 14 15 |
# File 'lib/rubex/ast/top_statement/klass.rb', line 13 def statements @statements end |
Instance Method Details
#analyse_statement(local_scope, attach_klass: false) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rubex/ast/top_statement/klass.rb', line 27 def analyse_statement(local_scope, attach_klass: false) @entry = local_scope.find(@name) @scope = @entry.type.scope @ancestor = @entry.type.ancestor add_statement_symbols_to_symbol_table unless attach_klass @statements.each do |stat| stat.analyse_statement @scope end end end |
#generate_code(code) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rubex/ast/top_statement/klass.rb', line 45 def generate_code(code) @scope.begin_block_callbacks.each do |cb| cb.generate_code code end @scope.no_gil_block_callbacks.each do |cb| cb.generate_code code end @statements.each do |stat| stat.generate_code code end end |
#rescan_declarations(_local_scope) ⇒ Object
39 40 41 42 43 |
# File 'lib/rubex/ast/top_statement/klass.rb', line 39 def rescan_declarations(_local_scope) @statements.each do |stat| stat&.rescan_declarations(@scope) end end |