diff --git a/ast/linking.yaml b/ast/linking.yaml index 3f3cb4f..72087c8 100644 --- a/ast/linking.yaml +++ b/ast/linking.yaml @@ -62,7 +62,10 @@ classes: - SymbolExecScope: super: SymbolScope - data: {} + data: + - locals: + - type: list> + is_ctor: false - SymbolExtendScope: super: SymbolScope @@ -104,7 +107,7 @@ classes: - type: UP - is_ctor: false - body: - - type: UP + - type: UP - is_ctor: false - SymbolRefPath: diff --git a/src/AstBuilderInt.cpp b/src/AstBuilderInt.cpp index fbfee3d..fef1da0 100644 --- a/src/AstBuilderInt.cpp +++ b/src/AstBuilderInt.cpp @@ -1584,11 +1584,11 @@ antlrcpp::Any AstBuilderInt::visitString_literal(PSSParser::String_literalContex DEBUG_ENTER("visitString_literal"); if (ctx->DOUBLE_QUOTED_STRING()) { std::string value = ctx->DOUBLE_QUOTED_STRING()->getText(); - value = value.substr(1, value.size()-1); + value = value.substr(1, value.size()-2); m_expr = m_factory->mkExprString(value, false); } else { std::string value = ctx->TRIPLE_DOUBLE_QUOTED_STRING()->getText(); - value = value.substr(3, value.size()-3); + value = value.substr(3, value.size()-6); m_expr = m_factory->mkExprString(value, true); } DEBUG_LEAVE("visitString_literal"); diff --git a/src/TaskBuildSymbolTree.cpp b/src/TaskBuildSymbolTree.cpp index 095076e..b55abaf 100644 --- a/src/TaskBuildSymbolTree.cpp +++ b/src/TaskBuildSymbolTree.cpp @@ -359,7 +359,7 @@ void TaskBuildSymbolTree::visitFunctionDefinition(ast::IFunctionDefinition *i) { // Build the body (and subscopes) symbol scopes int32_t id = func_sym->getChildren().size(); - ast::ISymbolScope *body = m_factory->mkSymbolScope(id, ""); + ast::ISymbolExecScope *body = m_factory->mkSymbolExecScope(id, ""); body->setLocation(i->getLocation()); body->setUpper(m_scope_s.back()); m_scope_s.push_back(body); @@ -537,8 +537,8 @@ void TaskBuildSymbolTree::visitPyImportFromStmt(ast::IPyImportFromStmt *i) { } void TaskBuildSymbolTree::visitProceduralStmtDataDeclaration(ast::IProceduralStmtDataDeclaration *i) { - DEBUG_ENTER("visitProceduralStmtDataDeclaration"); - ast::ISymbolScope *scope = m_scope_s.back(); + DEBUG_ENTER("visitProceduralStmtDataDeclaration %s", i->getName()->getId().c_str()); + ast::ISymbolExecScope *scope = dynamic_cast(m_scope_s.back()); std::map::const_iterator it = scope->getSymtab().find(i->getName()->getId()); @@ -551,6 +551,8 @@ void TaskBuildSymbolTree::visitProceduralStmtDataDeclaration(ast::IProceduralStm ); } else { int32_t id = scope->getChildren().size(); + DEBUG("DataDeclaration %s: %d", i->getName()->getId().c_str(), id); + scope->getLocals().push_back(i); scope->getSymtab().insert({i->getName()->getId(), id}); scope->getChildren().push_back(i); } diff --git a/src/TaskResolveRefs.cpp b/src/TaskResolveRefs.cpp index 6654aaa..a4c5069 100644 --- a/src/TaskResolveRefs.cpp +++ b/src/TaskResolveRefs.cpp @@ -455,13 +455,13 @@ void TaskResolveRefs::visitSymbolFunctionScope(ast::ISymbolFunctionScope *i) { m_symtab_it->pushScope(i); DEBUG(" has i: %d", (m_symtab_it->getScope()->getSymtab().find("i") != m_symtab_it->getScope()->getSymtab().end())); // DEBUG("Push function body scope"); -// m_symtab_it->pushScope(i->getBody()); + m_symtab_it->pushScope(i->getBody()); for (std::vector::const_iterator it=i->getBody()->getChildren().begin(); it!=i->getBody()->getChildren().end(); it++) { (*it)->accept(m_this); } - // m_symtab_it->popScope(); + m_symtab_it->popScope(); m_symtab_it->popScope(); } diff --git a/src/TaskResolveRootRef.cpp b/src/TaskResolveRootRef.cpp index 9d91f3d..73d2832 100644 --- a/src/TaskResolveRootRef.cpp +++ b/src/TaskResolveRootRef.cpp @@ -70,7 +70,7 @@ void TaskResolveRootRef::visitSymbolScope(ast::ISymbolScope *i) { DEBUG("imports: %p", i->getImports()); if (it != i->getSymtab().end()) { - DEBUG("Found symbol @ index %d", it->second); + DEBUG("Found symbol %s @ index %d", m_id->getId().c_str(), it->second); m_ref = m_scope->getScopeSymbolPath(); // Path to 'i' // Now, add in the child element that we just found @@ -90,7 +90,7 @@ void TaskResolveRootRef::visitSymbolScope(ast::ISymbolScope *i) { void TaskResolveRootRef::visitSymbolExecScope(ast::ISymbolExecScope *i) { DEBUG_ENTER("visitSymbolExecScope"); - + visitSymbolScope(i); DEBUG_LEAVE("visitSymbolExecScope"); }