Skip to content
Snippets Groups Projects
Commit 6f89dc67 authored by Fabian Vu's avatar Fabian Vu
Browse files

Invoke machine with external functions with correct parameters

parent c563a564
Branches
No related tags found
No related merge requests found
Pipeline #148966 passed
...@@ -8,6 +8,7 @@ import de.prob.parser.ast.nodes.DeclarationNode; ...@@ -8,6 +8,7 @@ import de.prob.parser.ast.nodes.DeclarationNode;
import de.prob.parser.ast.nodes.EnumeratedSetDeclarationNode; import de.prob.parser.ast.nodes.EnumeratedSetDeclarationNode;
import de.prob.parser.ast.nodes.MachineNode; import de.prob.parser.ast.nodes.MachineNode;
import de.prob.parser.ast.nodes.MachineReferenceNode; import de.prob.parser.ast.nodes.MachineReferenceNode;
import de.prob.parser.ast.nodes.OperationNode;
import de.prob.parser.ast.types.CoupleType; import de.prob.parser.ast.types.CoupleType;
import de.prob.parser.ast.types.SetType; import de.prob.parser.ast.types.SetType;
import org.stringtemplate.v4.ST; import org.stringtemplate.v4.ST;
...@@ -144,6 +145,11 @@ public class DeclarationGenerator { ...@@ -144,6 +145,11 @@ public class DeclarationGenerator {
ST declaration = currentGroup.getInstanceOf("include_declaration"); ST declaration = currentGroup.getInstanceOf("include_declaration");
String machine = reference.getMachineName(); String machine = reference.getMachineName();
String referenceName = reference.getPrefix() != null ? reference.getPrefix() : reference.getMachineName(); String referenceName = reference.getPrefix() != null ? reference.getPrefix() : reference.getMachineName();
boolean hasExternals = reference.getMachineNode().getOperations()
.stream()
.map(OperationNode::getName)
.anyMatch(op -> op.startsWith("EXTERNAL_"));
TemplateHandler.add(declaration, "hasExternals", hasExternals);
TemplateHandler.add(declaration, "type", nameHandler.handle(machine)); TemplateHandler.add(declaration, "type", nameHandler.handle(machine));
TemplateHandler.add(declaration, "identifier", nameHandler.handleIdentifier(referenceName, NameHandler.IdentifierHandlingEnum.MACHINES)); TemplateHandler.add(declaration, "identifier", nameHandler.handleIdentifier(referenceName, NameHandler.IdentifierHandlingEnum.MACHINES));
return declaration.render(); return declaration.render();
......
...@@ -590,8 +590,12 @@ bool() ::= << ...@@ -590,8 +590,12 @@ bool() ::= <<
BUtils.BOOL BUtils.BOOL
>> >>
include_declaration(type, identifier) ::= << include_declaration(hasExternals, type, identifier) ::= <<
<if(hasExternals)>
private <declaration(type, identifier)> = new <type>(new <type>_EXTERNALS());
<else>
private <declaration(type, identifier)> = new <type>(); private <declaration(type, identifier)> = new <type>();
<endif>
>> >>
global_declaration(type, identifier) ::= << global_declaration(type, identifier) ::= <<
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment