Class: Idl::GlobalAst
Constant Summary
Constants inherited
from AstNode
AstNode::Bits1Type, AstNode::Bits32Type, AstNode::Bits64Type, AstNode::BoolType, AstNode::ConstBoolType, AstNode::PossiblyUnknownBits1Type, AstNode::PossiblyUnknownBits32Type, AstNode::PossiblyUnknownBits64Type, AstNode::ReachableFunctionCacheType, AstNode::StringType, AstNode::VoidType
Instance Attribute Summary
Attributes inherited from AstNode
#children, #input, #interval, #parent
Class Method Summary
collapse
Instance Method Summary
collapse
#declaration?
Methods inherited from AstNode
#always_terminates?, #declaration?, #executable?, extract_base_var_name, #find_ancestor, #find_dst_registers, #find_referenced_csrs, #find_src_registers, #freeze_tree, #gen_adoc, #gen_option_adoc, #input_file, input_from_source_yaml, #inspect, #internal_error, interval_from_source_yaml, #lineno, #lines_around, #nullify_assignments, #pass_find_return_values, #path, #print_ast, #prune, #reachable_exceptions, #reachable_functions, #set_input_file, #set_input_file_unless_already_set, #source_line_file_offsets, #source_starting_offset, #source_yaml, #starting_line, #text_value, #truncation_warn, #type_error, #unindent, value_else, #value_else, value_error, #value_error, value_try, #value_try, write_back_nested
Constructor Details
#initialize(input, interval, declaration) ⇒ GlobalAst
Returns a new instance of GlobalAst.
1307
1308
1309
1310
|
# File 'lib/idlc/ast.rb', line 1307
def initialize(input, interval, declaration)
super(input, interval, [declaration])
declaration.make_global
end
|
Class Method Details
.from_h(yaml, source_mapper) ⇒ Object
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
|
# File 'lib/idlc/ast.rb', line 1337
def self.from_h(yaml, source_mapper)
raise "Bad YAML" unless yaml.key?("kind") && yaml.fetch("kind") == "global_var_decl"
input = input_from_source_yaml(yaml.fetch("source"), source_mapper)
interval = interval_from_source_yaml(yaml.fetch("source"))
GlobalAst.new(
input, interval,
VariableDeclarationAst.from_h(yaml.fetch("decl"), source_mapper)
)
end
|
Instance Method Details
#add_symbol(symtab) ⇒ Object
1320
1321
1322
1323
1324
|
# File 'lib/idlc/ast.rb', line 1320
def add_symbol(symtab)
internal_error "Should be at global scope" unless symtab.levels == 1
declaration.add_symbol(symtab)
end
|
#const_eval?(symtab) ⇒ Boolean
default initialization gives a value
1296
|
# File 'lib/idlc/ast.rb', line 1296
def const_eval?(symtab) = declaration.id.const?
|
1303
1304
1305
|
# File 'lib/idlc/ast.rb', line 1303
def declaration
@children[0]
end
|
#id ⇒ Object
1298
1299
1300
|
# File 'lib/idlc/ast.rb', line 1298
def id
declaration.id.text_value
end
|
#to_h ⇒ Object
1330
1331
1332
1333
1334
|
# File 'lib/idlc/ast.rb', line 1330
def to_h = {
"kind" => "global_var_decl",
"decl" => declaration.to_h,
"source" => source_yaml
}
|
#to_idl ⇒ Object
1327
|
# File 'lib/idlc/ast.rb', line 1327
def to_idl = declaration.to_idl
|
#type(symtab) ⇒ Object
1316
1317
1318
|
# File 'lib/idlc/ast.rb', line 1316
def type(symtab)
declaration.type(symtab)
end
|
#type_check(symtab, strict:) ⇒ Object
1312
1313
1314
|
# File 'lib/idlc/ast.rb', line 1312
def type_check(symtab, strict:)
declaration.type_check(symtab, strict:)
end
|