MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / handleStruct

Method handleStruct

erpcgen/src/SymbolScanner.cpp:686–736  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

684}
685
686AstNode *SymbolScanner::handleStruct(AstNode *node, top_down)
687{
688 AstNode *structNameNode = (*node)[0];
689 if (!structNameNode && m_currentAlias == nullptr)
690 {
691 throw semantic_error(format_string("line %d: illegal anonymous struct definition at file level",
692 node->getToken().getFirstLine()));
693 }
694
695 // Create the struct symbol.
696 StructType *newStruct;
697 if (structNameNode)
698 {
699 const Token &tok = structNameNode->getToken();
700 string name = tok.getStringValue();
701 Log::debug("struct: %s\n", name.c_str());
702
703 /* match forward declaration with definition */
704 auto forwardDecl = m_forwardDeclarations.find(name);
705 if (forwardDecl != m_forwardDeclarations.end())
706 {
707 newStruct = dynamic_cast<StructType *>(forwardDecl->second);
708 if (newStruct != nullptr)
709 {
710 new (newStruct) StructType(tok);
711 }
712 else
713 {
714 throw syntax_error(
715 format_string("line %d: Structure definition type name didn't match data type of "
716 "forward declaration from line %d.",
717 tok.getFirstLine(), forwardDecl->second->getFirstLine()));
718 }
719 }
720 else
721 {
722 newStruct = new StructType(tok);
723 }
724 }
725 else
726 {
727 Log::debug(
728 "typedef struct: %s\n",
729 check_null(check_null(check_null(node->getParent())->getChild(0))->getTokenValue())->toString().c_str());
730 newStruct = new StructType("");
731 }
732
733 m_currentStruct = newStruct;
734
735 return nullptr;
736}
737
738AstNode *SymbolScanner::handleStruct(AstNode *node, bottom_up)
739{

Callers

nothing calls this directly

Calls 15

semantic_errorClass · 0.85
format_stringFunction · 0.85
syntax_errorClass · 0.85
check_nullFunction · 0.85
internal_errorClass · 0.85
getTokenMethod · 0.80
getTokenValueMethod · 0.80
getChildMethod · 0.80
childCountMethod · 0.80
getFirstLineMethod · 0.45
endMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected