Class: Rubex::AST::Node::MainNode
- Defined in:
- lib/rubex/ast/node/main_node.rb
Overview
Main class that acts as the apex node of the Rubex AST.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #generate_common_utils_files(supervisor) ⇒ Object
- #generate_header_and_implementation(supervisor) ⇒ Object
-
#process_statements(target_name, supervisor) ⇒ Object
Central method that starts that processing of the AST.
Methods inherited from Base
#==, #add_top_statements_to_object_scope, #analyse_statement, #c_name_for_class, #call_dependent_init_methods, #create_symtab_entries_for_top_statements, #declare_unique_types, #define_classes, #define_instance_and_singleton_methods_for_all_classes, #generate_code, #generate_header_file, #generate_init_method, #init_function, #initialize, #object_or_stdlib_klass_scope, #outside_statement?, #rescan_declarations, #write_function_declarations, #write_global_variable_declarations, #write_outside_statements, #write_user_klasses
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
This class inherits a constructor from Rubex::AST::Node::Base
Instance Method Details
#generate_common_utils_files(supervisor) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rubex/ast/node/main_node.rb', line 27 def generate_common_utils_files supervisor supervisor.init_file(Rubex::COMMON_UTILS_FILE) header = supervisor.header(Rubex::COMMON_UTILS_FILE) header.in_header_guard(Rubex::COMMON_UTILS_CONST) do header << "#include <ruby.h>\n" header << "#include <stdint.h>\n" header << "#include <stdbool.h>\n" header << "#include <math.h>\n" write_usability_functions_header header write_usability_macros header end code = supervisor.code(Rubex::COMMON_UTILS_FILE) code.write_include(Rubex::COMMON_UTILS_FILE) write_usability_functions_code code Rubex::Compiler::CONFIG.add_dep(Rubex::COMMON_UTILS_FILE) end |
#generate_header_and_implementation(supervisor) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/rubex/ast/node/main_node.rb', line 46 def generate_header_and_implementation(supervisor) generate_header_file @file_name, supervisor.header(@file_name) code_writer = supervisor.code(@file_name) code_writer.write_include @file_name generate_code supervisor generate_init_method code_writer end |
#process_statements(target_name, supervisor) ⇒ Object
Central method that starts that processing of the AST. Called by Compiler.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rubex/ast/node/main_node.rb', line 13 def process_statements(target_name, supervisor) if target_name != @file_name raise Rubex::TargetFileMismatchError, "target_name #{target_name} does not match @file_name #{@file_name}" end @scope = Rubex::SymbolTable::Scope::Klass.new('Object', nil) add_top_statements_to_object_scope create_symtab_entries_for_top_statements(@scope) analyse_statement rescan_declarations @scope generate_common_utils_files supervisor generate_header_and_implementation supervisor end |