Commit 5f2575c7 authored by Thomas Michael Timmermanns's avatar Thomas Michael Timmermanns Committed by Thomas Michael Timmermanns

Implemented architecture parameters and removed IOParameters and Constants.

parent 94b95cfe
This diff is collapsed.
......@@ -30,7 +30,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnn-arch</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.1-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......
......@@ -5,7 +5,8 @@ grammar CNNArch extends de.monticore.lang.math.Math {
CNNArchCompilationUnit = Architecture;
symbol scope Architecture = "architecture"
name:Name& "{"
name:Name& "("
(ArchitectureParameter || ",")* ")" "{"
declarations:ArchDeclaration*
body:ArchBody "}";
......@@ -22,30 +23,31 @@ grammar CNNArch extends de.monticore.lang.math.Math {
ArchType implements Type = ElementType "^" Shape;
Shape = "{" (Dimension || ",")+ "}";
Shape = "{" dimensions:(ArchSimpleExpression || ",")+ "}";
Dimension = IOVariable | intLiteral:UnitNumberResolution;
IOVariable implements Variable = Name& ("=" intRhs:UnitNumberResolution)?;
VariableAssignment implements Variable,ArchDeclaration = Name& "=" rhs:ArchSimpleExpression;
ArchitectureParameter implements Variable = Name& ("=" default:ArchSimpleExpression)?;
MethodDeclaration implements ArchDeclaration = "def"
Name& "("
parameters:(Parameter || ",")* ")" "{"
parameters:(MethodParameter || ",")* ")" "{"
body:ArchBody "}";
Parameter implements Variable = Name& ("=" default:ArchSimpleExpression)?;
MethodParameter implements Variable = Name& ("=" default:ArchSimpleExpression)?;
scope ArchBody = elements:(ArchitectureElement || "->")*;
IOLayer implements ArchitectureElement = Name& ("[" index:ArchSimpleExpression "]")?;
MethodLayer implements ArchitectureElement = Name& "(" arguments:(Argument || ",")* ")";
MethodLayer implements ArchitectureElement = Name& "(" arguments:(ArchArgument || ",")* ")";
interface ArchArgument;
ast ArchArgument = method String getName(){}
method ASTArchExpression getRhs(){};
Argument = Name "=" rhs:ArchExpression;
ArchParameterArgument implements ArchArgument = Name "=" rhs:ArchExpression;
PredefinedArgument extends Argument = (serial:"->" | parallel:"|") "=" rhs2:ArchExpression;
ArchSpecialArgument implements ArchArgument = (serial:"->" | parallel:"|") "=" rhs:ArchExpression;
ast ArchSpecialArgument = method public String getName(){return "";};
ParallelLayer implements ArchitectureElement = "(" groups:ArchBody "|" groups:(ArchBody || "|")+ ")";
......
......@@ -22,34 +22,24 @@ package de.monticore.lang.monticar.cnnarch._ast;
import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedVariables;
public class ASTPredefinedArgument extends ASTPredefinedArgumentTOP {
public class ASTArchSpecialArgument extends ASTArchSpecialArgumentTOP {
public ASTPredefinedArgument() {
public ASTArchSpecialArgument() {
}
public ASTPredefinedArgument(ASTArchExpression rhs2, String serial, String parallel, String name, ASTArchExpression rhs) {
super(rhs2, serial, parallel, name, rhs);
public ASTArchSpecialArgument(ASTArchExpression rhs, String serial, String parallel) {
super(rhs, serial, parallel);
}
@Override
public void setRhs2(ASTArchExpression rhs2) {
super.setRhs2(rhs2);
setRhs(rhs2);
}
@Override
public void setParallel(String parallel) {
super.setParallel(parallel);
if (parallel != null && !parallel.isEmpty()){
setName(AllPredefinedVariables.CARDINALITY_NAME);
public String getName() {
if (getParallel().isPresent()){
return AllPredefinedVariables.CARDINALITY_NAME;
}
}
@Override
public void setSerial(String serial) {
super.setSerial(serial);
if (serial != null && !serial.isEmpty()) {
setName(AllPredefinedVariables.FOR_NAME);
else if (getSerial().isPresent()) {
return AllPredefinedVariables.FOR_NAME;
}
return null;
}
}
......@@ -26,7 +26,8 @@ public class CNNArchPostResolveCocos {
return new CNNArchCoCoChecker()
.addCoCo(new CheckLayerInputs())
.addCoCo(new CheckIOAccessAndIOMissing())
.addCoCo(new CheckIOType());
.addCoCo(new CheckIOType())
.addCoCo(new CheckIOShape());
}
}
......@@ -28,8 +28,8 @@ public class CNNArchPreResolveCocos {
.addCoCo(new CheckIOName())
.addCoCo(new CheckNameExpression())
.addCoCo(new CheckMethodLayer())
.addCoCo(new CheckRangeOperators())
.addCoCo(new CheckVariableName())
.addCoCo(new CheckIOShape())
.addCoCo(new CheckUnknownIO())
.addCoCo(new CheckArgument())
.addCoCo(new CheckMethodName())
......
......@@ -20,15 +20,15 @@
*/
package de.monticore.lang.monticar.cnnarch._cocos;
import de.monticore.lang.monticar.cnnarch._ast.ASTArgument;
import de.monticore.lang.monticar.cnnarch._ast.ASTArchArgument;
import de.monticore.lang.monticar.cnnarch._symboltable.ArgumentSymbol;
import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes;
import de.se_rwth.commons.logging.Log;
public class CheckArgument implements CNNArchASTArgumentCoCo {
public class CheckArgument implements CNNArchASTArchArgumentCoCo {
@Override
public void check(ASTArgument node) {
public void check(ASTArchArgument node) {
ArgumentSymbol argument = (ArgumentSymbol) node.getSymbol().get();
if (argument.getParameter() == null){
Log.error("0"+ ErrorCodes.UNKNOWN_ARGUMENT_CODE + " Unknown Argument. " +
......
......@@ -75,7 +75,8 @@ public class CheckIOAccessAndIOMissing implements CNNArchASTIODeclarationCoCo {
unusedIndices.remove(arrayAccess.get());
}
else {
Log.error("0" + ErrorCodes.INVALID_ARRAY_ACCESS + " The IO array access value must be an integer between 0 and " + (ioDeclaration.getArrayLength()-1) + ". " +
Log.error("0" + ErrorCodes.INVALID_ARRAY_ACCESS + " The IO array access value of '" + layer.getName() +
"' must be an integer between 0 and " + (ioDeclaration.getArrayLength()-1) + ". " +
"The current value is: " + layer.getArrayAccess().get().getValue().get().toString()
, layer.getSourcePosition());
}
......
......@@ -20,13 +20,11 @@
*/
package de.monticore.lang.monticar.cnnarch._cocos;
import de.monticore.lang.monticar.cnnarch._ast.ASTDimension;
import de.monticore.lang.monticar.cnnarch._ast.ASTIODeclaration;
import de.monticore.lang.monticar.cnnarch._symboltable.ShapeSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchSimpleExpressionSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.IODeclarationSymbol;
import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes;
import de.monticore.lang.monticar.types2._ast.ASTUnitNumberResolution;
import de.se_rwth.commons.logging.Log;
import org.jscience.mathematics.number.Rational;
import java.util.Optional;
......@@ -41,18 +39,13 @@ public class CheckIOShape implements CNNArchASTIODeclarationCoCo {
, node.getType().getShape().get_SourcePositionStart());
}
else {
for (ASTDimension dimension : node.getType().getShape().getDimensions()){
Rational rational;
if (dimension.getIntLiteral().isPresent()){
rational = dimension.getIntLiteral().get().getNumber().get();
}
else {
rational = dimension.getIOVariable().get().getIntRhs().get().getNumber().get();
}
if (rational.getDivisor().intValue() != 1 || !rational.isPositive()){
IODeclarationSymbol ioDeclaration = (IODeclarationSymbol) node.getSymbol().get();
for (ArchSimpleExpressionSymbol dimension : ioDeclaration.getShape().getDimensionSymbols()){
Optional<Integer> value = dimension.getIntValue();
if (!value.isPresent() || value.get() <= 0){
Log.error("0" + ErrorCodes.INVALID_IO_SHAPE + " Invalid shape. " +
"The dimension can only be defined by a positive integer."
, dimension.get_SourcePositionStart());
, dimension.getSourcePosition());
}
}
}
......
......@@ -20,7 +20,7 @@
*/
package de.monticore.lang.monticar.cnnarch._cocos;
import de.monticore.lang.monticar.cnnarch._ast.ASTArgument;
import de.monticore.lang.monticar.cnnarch._ast.ASTArchArgument;
import de.monticore.lang.monticar.cnnarch._ast.ASTMethodLayer;
import de.monticore.lang.monticar.cnnarch._symboltable.MethodDeclarationSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.MethodLayerSymbol;
......@@ -37,7 +37,7 @@ public class CheckMethodLayer implements CNNArchASTMethodLayerCoCo{
@Override
public void check(ASTMethodLayer node) {
Set<String> nameSet = new HashSet<>();
for (ASTArgument argument : node.getArguments()){
for (ASTArchArgument argument : node.getArguments()){
String name = argument.getName();
if (nameSet.contains(name)){
Log.error("0" + ErrorCodes.DUPLICATED_ARG_CODE + " Duplicated name: " + name +
......@@ -62,7 +62,7 @@ public class CheckMethodLayer implements CNNArchASTMethodLayerCoCo{
requiredArguments.add(param.getName());
}
}
for (ASTArgument argument : node.getArguments()){
for (ASTArchArgument argument : node.getArguments()){
requiredArguments.remove(argument.getName());
if (argument.getName().equals(AllPredefinedMethods.GLOBAL_NAME)){
requiredArguments.remove(AllPredefinedMethods.KERNEL_NAME);
......
......@@ -20,8 +20,6 @@
*/
package de.monticore.lang.monticar.cnnarch._cocos;
import de.monticore.lang.math.math._ast.ASTMathNameExpression;
import de.monticore.lang.math.math._cocos.MathASTMathNameExpressionCoCo;
import de.monticore.lang.math.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.math.math._symboltable.expression.MathNameExpressionSymbol;
import de.monticore.lang.monticar.cnnarch._ast.ASTArchSimpleExpression;
......@@ -31,7 +29,7 @@ import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes;
import de.monticore.lang.monticar.cnnarch.helper.ExpressionHelper;
import de.se_rwth.commons.logging.Log;
import java.util.Optional;
import java.util.Collection;
public class CheckNameExpression implements CNNArchASTArchSimpleExpressionCoCo {
......@@ -44,9 +42,9 @@ public class CheckNameExpression implements CNNArchASTArchSimpleExpressionCoCo {
for (MathExpressionSymbol subMathExp : ExpressionHelper.createSubExpressionList(mathExpression)){
if (subMathExp instanceof MathNameExpressionSymbol){
String name = ((MathNameExpressionSymbol) subMathExp).getNameToAccess();
Optional<VariableSymbol> variable = node.getEnclosingScope().get().resolve(name, VariableSymbol.KIND);
Collection<VariableSymbol> variableCollection = node.getEnclosingScope().get().resolveMany(name, VariableSymbol.KIND);
if (!variable.isPresent()){
if (variableCollection.isEmpty()){
Log.error("0" + ErrorCodes.UNKNOWN_VARIABLE_NAME + " Unknown variable name. " +
"The variable '" + name + "' does not exist. "
, subMathExp.getSourcePosition());
......
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package de.monticore.lang.monticar.cnnarch._cocos;
import de.monticore.lang.monticar.cnnarch._ast.ASTArchValueRange;
import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes;
import de.se_rwth.commons.logging.Log;
public class CheckRangeOperators implements CNNArchASTArchValueRangeCoCo {
@Override
public void check(ASTArchValueRange node) {
if (node.getParallel().isPresent()){
if (!node.getParallel2().isPresent()){
differentOperatorError(node);
}
}
else {
if (node.getParallel2().isPresent()){
differentOperatorError(node);
}
}
}
private void differentOperatorError(ASTArchValueRange node){
Log.error("0" + ErrorCodes.DIFFERENT_RANGE_OPERATORS +
" the second layer operator ('->' or '|') in a range has to be identical to the first one."
, node.get_SourcePositionStart());
}
}
......@@ -20,7 +20,7 @@
*/
package de.monticore.lang.monticar.cnnarch._cocos;
import de.monticore.lang.monticar.cnnarch._ast.ASTParameter;
import de.monticore.lang.monticar.cnnarch._ast.ASTMethodParameter;
import de.monticore.lang.monticar.cnnarch._ast.ASTVariable;
import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes;
import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedVariables;
......@@ -64,7 +64,7 @@ public class CheckVariableName implements CNNArchASTVariableCoCo {
private void checkForDuplicates(ASTVariable node){
String name = node.getName();
if (variableNames.contains(name)){
if (node instanceof ASTParameter){
if (node instanceof ASTMethodParameter){
Collection<Symbol> allParametersWithSameName = node.getEnclosingScope().get().getLocalSymbols().get(name);
if (allParametersWithSameName.size() > 1){
duplicationError(node);
......
......@@ -69,7 +69,7 @@ public class ArchSimpleExpressionSymbol extends ArchExpressionSymbol {
@Override
public boolean isBoolean() {
if (getMathExpression().isPresent() && !(getMathExpression().get() instanceof MathNameExpressionSymbol)){
if (getMathExpression().isPresent() && !(getMathExpression().get().getRealMathExpressionSymbol() instanceof MathNameExpressionSymbol)){
if (getMathExpression().get().getRealMathExpressionSymbol() instanceof MathCompareExpressionSymbol){
return true;
}
......@@ -90,7 +90,7 @@ public class ArchSimpleExpressionSymbol extends ArchExpressionSymbol {
@Override
public boolean isTuple() {
if (getMathExpression().isPresent() && !(getMathExpression().get() instanceof MathNameExpressionSymbol)){
if (getMathExpression().isPresent() && !(getMathExpression().get().getRealMathExpressionSymbol() instanceof MathNameExpressionSymbol)){
if (getMathExpression().get().getRealMathExpressionSymbol() instanceof TupleExpressionSymbol){
return true;
}
......
......@@ -23,7 +23,13 @@
package de.monticore.lang.monticar.cnnarch._symboltable;
import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes;
import de.se_rwth.commons.Joiners;
import de.se_rwth.commons.logging.Log;
import org.jscience.mathematics.number.Rational;
import java.util.List;
import java.util.Optional;
import java.util.Set;
public class ArchitectureSymbol extends ArchitectureSymbolTOP {
......@@ -31,6 +37,7 @@ public class ArchitectureSymbol extends ArchitectureSymbolTOP {
private LayerSymbol body;
private List<IODeclarationSymbol> inputs;
private List<IODeclarationSymbol> outputs;
private List<VariableSymbol> parameters;
public ArchitectureSymbol(String name) {
super(name);
......@@ -45,7 +52,7 @@ public class ArchitectureSymbol extends ArchitectureSymbolTOP {
return body;
}
public void setBody(LayerSymbol body) {
protected void setBody(LayerSymbol body) {
this.body = body;
}
......@@ -53,7 +60,7 @@ public class ArchitectureSymbol extends ArchitectureSymbolTOP {
return inputs;
}
public void setInputs(List<IODeclarationSymbol> inputs) {
protected void setInputs(List<IODeclarationSymbol> inputs) {
this.inputs = inputs;
}
......@@ -61,11 +68,20 @@ public class ArchitectureSymbol extends ArchitectureSymbolTOP {
return outputs;
}
public void setOutputs(List<IODeclarationSymbol> outputs) {
protected void setOutputs(List<IODeclarationSymbol> outputs) {
this.outputs = outputs;
}
public List<VariableSymbol> getParameters() {
return parameters;
}
protected void setParameters(List<VariableSymbol> parameters) {
this.parameters = parameters;
}
public void resolve(){
checkParameters();
getBody().checkIfResolvable();
try{
getBody().resolve();
......@@ -75,6 +91,13 @@ public class ArchitectureSymbol extends ArchitectureSymbolTOP {
}
}
public void resolveOrError(){
resolve();
if (!isResolved()){
throw new IllegalStateException("The following names could not be resolved: " + Joiners.COMMA.join(getUnresolvableVariables()));
}
}
public List<LayerSymbol> getFirstLayers(){
if (!getBody().isResolved()){
resolve();
......@@ -86,7 +109,87 @@ public class ArchitectureSymbol extends ArchitectureSymbolTOP {
return getBody().isResolved();
}
public boolean isResolvable(){
return getBody().isResolvable();
}
public Set<VariableSymbol> getUnresolvableVariables(){
return getBody().getUnresolvableVariables();
}
public void checkParameters(){
for (VariableSymbol parameter : getParameters()){
if (!parameter.hasExpression()){
Log.error("0" + ErrorCodes.MISSING_VAR_VALUE_CODE + " Missing architecture argument. " +
"The parameter '" + parameter.getName() + "' has no value.");
}
}
}
public Optional<IODeclarationSymbol> getInput(String name){
for (IODeclarationSymbol input : getInputs()){
if (input.getName().equals(name)){
return Optional.of(input);
}
}
return Optional.empty();
}
public Optional<IODeclarationSymbol> getOutput(String name){
for (IODeclarationSymbol output : getOutputs()){
if (output.getName().equals(name)){
return Optional.of(output);
}
}
return Optional.empty();
}
public Optional<VariableSymbol> getParameter(String name){
for (VariableSymbol parameter : getParameters()){
if (parameter.getName().equals(name)){
return Optional.of(parameter);
}
}
return Optional.empty();
}
private VariableSymbol getParameterOrError(String name){
Optional<VariableSymbol> param = getParameter(name);
if (param.isPresent()){
return param.get();
}
else {
throw new IllegalArgumentException("architecture parameter with name " + name + " does not exist.");
}
}
public void setParameter(String name, Rational value){
VariableSymbol parameter = getParameterOrError(name);
if (value.getDivisor().intValue() == 1){
parameter.setExpression(ArchSimpleExpressionSymbol.of(value.getDividend().intValue()));
}
else {
parameter.setExpression(ArchSimpleExpressionSymbol.of(value.doubleValue()));
}
}
public void setParameter(String name, boolean value){
VariableSymbol parameter = getParameterOrError(name);
parameter.setExpression(ArchSimpleExpressionSymbol.of(value));
}
public void setParameter(String name, int value){
VariableSymbol parameter = getParameterOrError(name);
parameter.setExpression(ArchSimpleExpressionSymbol.of(value));
}
public void setParameter(String name, double value){
VariableSymbol parameter = getParameterOrError(name);
parameter.setExpression(ArchSimpleExpressionSymbol.of(value));
}
public void setParameter(String name, String value){
VariableSymbol parameter = getParameterOrError(name);
parameter.setExpression(ArchSimpleExpressionSymbol.of(value));
}
}
......@@ -40,7 +40,7 @@ public class CNNArchLanguage extends CNNArchLanguageTOP {
protected void initResolvingFilters() {
super.initResolvingFilters();
//addResolvingFilter(CommonResolvingFilter.create(MathExpressionSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(ArchitectureSymbol.KIND));
addResolvingFilter(new ArchitectureResolvingFilter());
addResolvingFilter(CommonResolvingFilter.create(MethodDeclarationSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(LayerSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(VariableSymbol.KIND));
......
......@@ -94,7 +94,6 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
}
}
@Override
public void visit(final ASTCNNArchCompilationUnit compilationUnit) {
Log.debug("Building Symboltable for Script: " + compilationUnit.getArchitecture().getName(),
......@@ -131,6 +130,12 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
architecture.setInputs(inputs);
architecture.setOutputs(outputs);
List<VariableSymbol> parameters = new ArrayList<>(node.getArchitectureParameters().size());
for (ASTArchitectureParameter astParameter : node.getArchitectureParameters()){
parameters.add((VariableSymbol) astParameter.getSymbol().get());
}
architecture.setParameters(parameters);
removeCurrentScope();
}
......@@ -145,6 +150,17 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
}
}
@Override
public void endVisit(ASTArchitectureParameter node) {
VariableSymbol variable = new VariableSymbol(node.getName());
variable.setType(VariableType.ARCHITECTURE_PARAMETER);
if (node.getDefault().isPresent()){
variable.setDefaultExpression((ArchSimpleExpressionSymbol) node.getDefault().get().getSymbol().get());
}
addToScopeAndLinkWithNode(variable, node);
}
@Override
public void visit(ASTIODeclaration ast) {
IODeclarationSymbol iODeclaration = new IODeclarationSymbol(ast.getName());
......@@ -200,33 +216,6 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
addToScopeAndLinkWithNode(sym, node);
}
@Override
public void endVisit(ASTDimension node) {
ArchSimpleExpressionSymbol sym;
if (node.getIntLiteral().isPresent()){
sym = ArchSimpleExpressionSymbol.of(node.getIntLiteral().get().getNumber().get().getDividend().intValue());
}
else {
sym = ArchSimpleExpressionSymbol.of((VariableSymbol) node.getIOVariable().get().getSymbol().get());
}
addToScopeAndLinkWithNode(sym, node);
}
@Override
public void endVisit(ASTIOVariable node) {
ArchSimpleExpressionSymbol defaultValue = null;
if (node.getIntRhs().isPresent()){
defaultValue = ArchSimpleExpressionSymbol.of(node.getIntRhs().get().getNumber().get().getDividend().intValue());
}
VariableSymbol variable = new VariableSymbol.Builder()
.name(node.getName())
.type(VariableType.IOVARIABLE)
.defaultValue(defaultValue)
.build();
//addToScope(ArchSimpleExpressionSymbol.of(variable));
addToScopeAndLinkWithNode(variable, node);
}
@Override
public void visit(ASTMethodDeclaration ast) {
MethodDeclarationSymbol methodDeclaration = new MethodDeclarationSymbol(ast.getName());
......@@ -239,7 +228,7 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
methodDeclaration.setBody((CompositeLayerSymbol) ast.getBody().getSymbol().get());
List<VariableSymbol> parameters = new ArrayList<>(4);
for (ASTParameter astParam : ast.getParameters()){
for (ASTMethodParameter astParam : ast.getParameters()){
VariableSymbol parameter = (VariableSymbol) astParam.getSymbol().get();
parameters.add(parameter);
}
......@@ -249,28 +238,20 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
}
@Override
public void visit(ASTParameter ast) {
public void visit(ASTMethodParameter ast) {
VariableSymbol variable = new VariableSymbol(ast.getName());
variable.setType(VariableType.PARAMETER);
variable.setType(VariableType.METHOD_PARAMETER);
addToScopeAndLinkWithNode(variable, ast);
}
@Override
public void endVisit(ASTParameter ast) {
public void endVisit(ASTMethodParameter ast) {
VariableSymbol variable = (VariableSymbol) ast.getSymbol().get();
if (ast.getDefault().isPresent()){
variable.setDefaultExpression((ArchSimpleExpressionSymbol) ast.getDefault().get().getSymbol().get());
}
}
@Override
public void endVisit(ASTVariableAssignment node) {
VariableSymbol variable = new VariableSymbol(node.getName());
variable.setType(VariableType.CONSTANT);
variable.setDefaultExpression((ArchSimpleExpressionSymbol) node.getRhs().getSymbol().get());
addToScopeAndLinkWithNode(variable, node);
}
@Override