MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / gc_node_at

Function gc_node_at

src/ast/ast_gc_report.cpp:17–28  ·  view source on GitHub ↗

---- per-tag downcast ---- Only the AST layer knows the concrete subclass behind each gc tag, so this is the one place that can recover a node's source `at`. MakeStruct (and any untagged node) carries no `at` of its own -> nullptr.

Source from the content-addressed store, hash-verified

15 // one place that can recover a node's source `at`. MakeStruct (and any untagged node)
16 // carries no `at` of its own -> nullptr.
17 static const LineInfo * gc_node_at ( const gc_node * node ) {
18 switch ( node->gc_type_tag() ) {
19 case GC_TAG_TYPEDECL: return &static_cast<const TypeDecl*>(node)->at;
20 case GC_TAG_EXPRESSION: return &static_cast<const Expression*>(node)->at;
21 case GC_TAG_MAKEFIELDDECL: return &static_cast<const MakeFieldDecl*>(node)->at;
22 case GC_TAG_FUNCTION: return &static_cast<const Function*>(node)->at;
23 case GC_TAG_ENUMERATION: return &static_cast<const Enumeration*>(node)->at;
24 case GC_TAG_STRUCTURE: return &static_cast<const Structure*>(node)->at;
25 case GC_TAG_VARIABLE: return &static_cast<const Variable*>(node)->at;
26 default: return nullptr; // MakeStruct, untagged, builtins
27 }
28 }
29
30 static const char * gc_tag_name ( uint16_t tag ) {
31 switch ( tag ) {

Callers 2

gc_describe_implFunction · 0.85
gc_build_histogramFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected