@@ -745,13 +745,13 @@ Parser2::parseFunctionInOut(const std::string& name)
745745 outputBuffer +=
746746 " , " + builtinTypesTranslator (type) + " " + name;
747747 else
748- outputBuffer += type + " " + name;
748+ outputBuffer += builtinTypesTranslator ( type) + " " + name;
749749 else if (!isUdt)
750750 {
751751 if (outputBuffer != " " )
752752 outputBuffer += " , " + builtinTypesTranslator (type);
753753 else
754- outputBuffer += type;
754+ outputBuffer += builtinTypesTranslator ( type) ;
755755 }
756756
757757 if (type == " void" )
@@ -776,7 +776,11 @@ Parser2::parseFunctionInOut(const std::string& name)
776776 // outputs
777777 advanceAndCheckToken (TokenKind::LPAREN); // consume l paren
778778 auto output = parseType ();
779+
779780 types += " )" + output;
781+
782+ if (udttable->hasUDT (output))
783+ output = " struct " + output + " *" ;
780784 advanceAndCheckToken (TokenKind::RPAREN); // consume r paren
781785
782786 if (isUdt)
@@ -1519,6 +1523,7 @@ std::string
15191523Parser2::parseUDTDec ()
15201524{
15211525 auto udtName = parseIdentifier ();
1526+
15221527 targetBuffer +=
15231528 " (struct " + udtName + " *)malloc(sizeof(struct " + udtName + " ));\n " ;
15241529
@@ -1539,9 +1544,18 @@ Parser2::parseUDTDec()
15391544
15401545 advanceAndCheckToken (TokenKind::COLON); // consume ':'
15411546
1547+ std::string temp = decName;
1548+ if (currentToken->value .at (0 ) == ' [' )
1549+ {
1550+ decName = decName + " ->" + attributeName;
1551+ decType = st->getSymbolType (attributeName);
1552+ }
1553+
15421554 // capture value
15431555 auto type = parsePrimary ();
15441556
1557+ decName = temp;
1558+
15451559 if (attributes.size () != 1 )
15461560 this ->targetBuffer += " ;\n " ;
15471561
@@ -1571,7 +1585,6 @@ Parser2::parseUDTDec()
15711585 " Expected " + std::to_string (st->getSymbols ().size ()) +
15721586 " keys and received " ,
15731587 std::to_string (st->getSymbols ().size () - attributes.size ()), " ." )));
1574-
15751588 return udtName;
15761589}
15771590
@@ -1637,8 +1650,8 @@ Parser2::parsePrimary()
16371650
16381651 if (methodAccessName == " " ||
16391652 (methodAccessName != " " && type != " void" ))
1640- if (!udttable->hasUDT (symboltable->getSymbolType (type)))
1641- targetBuffer += builtinTypesTranslator (type);
1653+ // if (!udttable->hasUDT(symboltable->getSymbolType(type)))
1654+ targetBuffer += builtinTypesTranslator (type);
16421655
16431656 return type;
16441657 }
@@ -1833,7 +1846,7 @@ Parser2::parseList()
18331846 advanceAndCheckToken (TokenKind::LIST); // eat list
18341847 auto listVals = determineTypes (parseListValues (v));
18351848
1836- std::string type = " none " ;
1849+ std::string type = decType ;
18371850
18381851 std::deque<std::string> vals;
18391852 if (listVals.size () != 0 )
0 commit comments