Skip to content

Commit

Permalink
Merge branch 'tc3-symtab' into 'dev'
Browse files Browse the repository at this point in the history
Add symtab-completion for typecheck 3

See merge request monticore/monticore!1055
  • Loading branch information
schmalzing committed Oct 31, 2024
2 parents d8e74c2 + 6bf4de0 commit d113eb0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import de.monticore.types.check.TypeCheckResult;
import de.monticore.types.mcbasictypes._ast.ASTMCType;

/**
* @deprecated Use {@link MCCommonStatementsSymTabCompletion} instead
*/
@Deprecated
public class MCCommonStatementsSTCompleteTypes implements MCCommonStatementsVisitor2 {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*(c) https://github.com/MontiCore/monticore*/
package de.monticore.statements.mccommonstatements._symboltable;

import de.monticore.statements.mccommonstatements._ast.ASTFormalParameter;
import de.monticore.statements.mccommonstatements._visitor.MCCommonStatementsVisitor2;
import de.monticore.symbols.oosymbols._symboltable.FieldSymbol;
import de.monticore.types3.TypeCheck3;

public class MCCommonStatementsSymTabCompletion implements MCCommonStatementsVisitor2 {

@Override
public void endVisit(ASTFormalParameter ast) {
FieldSymbol symbol = ast.getDeclarator().getSymbol();
symbol.setType(TypeCheck3.symTypeFromAST(ast.getMCType()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

import java.util.List;

/**
* @deprecated Use {@link MCVarDeclarationStatementsSymTabCompletion} instead
*/
@Deprecated
public class MCVarDeclarationStatementsSTCompleteTypes implements MCVarDeclarationStatementsVisitor2 {

protected ISynthesize typeSynthesizer;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*(c) https://github.com/MontiCore/monticore*/
package de.monticore.statements.mcvardeclarationstatements._symboltable;

import de.monticore.statements.mcvardeclarationstatements._ast.ASTLocalVariableDeclaration;
import de.monticore.statements.mcvardeclarationstatements._ast.ASTVariableDeclarator;
import de.monticore.statements.mcvardeclarationstatements._visitor.MCVarDeclarationStatementsVisitor2;
import de.monticore.types3.TypeCheck3;

public class MCVarDeclarationStatementsSymTabCompletion implements MCVarDeclarationStatementsVisitor2 {

public MCVarDeclarationStatementsSymTabCompletion() { }

public void endVisit(ASTLocalVariableDeclaration ast) {
for (ASTVariableDeclarator v : ast.getVariableDeclaratorList()) {
v.getDeclarator().getSymbol().setType(TypeCheck3.symTypeFromAST(ast.getMCType()));
}
}
}

0 comments on commit d113eb0

Please sign in to comment.