・JumpGame.model の変数名の誤りの修正.
・ref ポートに定義されたリソースをコンストラクタの引数として渡し,フィールドの初期化を行うようにする.
・コンパイルエラーが出るので,タプル型フィールドの初期化は行わないようにする.(リスト型フィールドのみ初期化する.)
・小数の定数を double 型,整数の定数を int 型として解釈するようにする.
1 parent 53a15be commit 0b39d4ef0080e73354c39d64b78cc742b7a1ec17
Naoya Nitta authored on 1 Sep 2021
Showing 4 changed files
View
2
■■■
AlgebraicDataflowArchitectureModel/models/JumpGame.model
 
channel C5 {
in position(p, update2(p2, g2)) == p2
in ground(g, update2(p2, g2)) == g2
out onground(o:Bool, update2(p2, g2)) == and(eq(g2, true), le(snd(p), 0.0))
out onground(o:Bool, update2(p2, g2)) == and(eq(g2, true), le(snd(p2), 0.0))
}
 
channel C6 {
in position(p, update6(p2)) == p2
View
45
AlgebraicDataflowArchitectureModel/src/algorithms/JavaCodeGenerator.java
import models.dataConstraintModel.ChannelMember;
import models.dataConstraintModel.DataConstraintModel;
import models.dataConstraintModel.IdentifierTemplate;
import models.dataFlowModel.DataFlowModel;
import models.dataFlowModel.DataflowChannelGenerator;
import models.dataFlowModel.DataflowChannelGenerator.IResourceStateAccessor;
import models.dataFlowModel.PushPullAttribute;
import models.dataFlowModel.PushPullValue;
import models.dataFlowModel.ResourceDependency;
if (rn.getIndegree() > 1) {
// Declare a field to cash the state of the source resource in the type of the destination resource.
String cashInitializer = null;
Type cashType = ((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceStateType();
if (DataConstraintModel.typeList.isAncestorOf(cashType) || DataConstraintModel.typeTuple.isAncestorOf(cashType)) {
if (DataConstraintModel.typeList.isAncestorOf(cashType)) {
cashInitializer = "new " + cashType.getImplementationTypeName() + "()";
}
type.addField(new FieldDeclaration(
cashType, ((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceName(), cashInitializer));
}
}
}
Set<IdentifierTemplate> refs = new HashSet<>();
for (ChannelGenerator cg : model.getChannelGenerators()) {
DataflowChannelGenerator c = (DataflowChannelGenerator) cg;
if (c.getOutputIdentifierTemplates().contains(rn.getIdentifierTemplate())) {
for (IdentifierTemplate id: c.getReferenceIdentifierTemplates()) {
if (!refs.contains(id)) {
refs.add(id);
String refResName = id.getResourceName();
fieldInitializer += refResName.toLowerCase() + ",";
f = true;
}
}
}
}
if (f)
vars.add(new VariableDeclaration(
((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceStateType(),
((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceName()));
type.addMethod(new MethodDeclaration("update" + srcResName, false, typeVoid, vars));
}
}
// Declare a field to refer to the reference resource.
refs = new HashSet<>();
for (ChannelGenerator cg : model.getChannelGenerators()) {
DataflowChannelGenerator c = (DataflowChannelGenerator) cg;
if (c.getOutputIdentifierTemplates().contains(rn.getIdentifierTemplate())) {
for (IdentifierTemplate id: c.getReferenceIdentifierTemplates()) {
if (!refs.contains(id)) {
refs.add(id);
String refResName = id.getResourceName();
refResName = refResName.substring(0, 1).toUpperCase() + refResName.substring(1);
type.addField(new FieldDeclaration(new Type(refResName, refResName), id.getResourceName()));
constructor.addParameter(new VariableDeclaration(new Type(refResName, refResName), id.getResourceName()));
block.addStatement("this." + refResName.toLowerCase() + " = " + refResName.toLowerCase() + ";");
constructor.setBody(block);
}
}
}
}
if (constructor.getParameters() != null)
type.addMethod(constructor);
}
// Declare the field to store the state in the type of each resource.
if (((StoreAttribute) rn.getAttribute()).isStored()) {
String str = "new " + rn.getIdentifierTemplate().getResourceStateType().getImplementationTypeName()
+ "()";
String initializer = "new " + rn.getIdentifierTemplate().getResourceStateType().getImplementationTypeName() + "()";
Type stateType = rn.getIdentifierTemplate().getResourceStateType();
if (!DataConstraintModel.typeList.isAncestorOf(stateType) && !DataConstraintModel.typeTuple.isAncestorOf(stateType))
str = null;
type.addField(new FieldDeclaration(stateType, rn.getIdentifierTemplate().getResourceName(), str));
if (!DataConstraintModel.typeList.isAncestorOf(stateType)) initializer = null;
type.addField(new FieldDeclaration(stateType, rn.getIdentifierTemplate().getResourceName(), initializer));
}
// Declare the getter method to obtain the state in the type of each resource.
type.addMethod(new MethodDeclaration("get" + type.getTypeName(),
View
6
AlgebraicDataflowArchitectureModel/src/algorithms/JerseyCodeGenerator.java
update.addAnnotation(new Annotation("Path", "\"/" + srcName + "\""));
// Declare a field to cash the state of the source resource in the type of the destination resource.
String cashInitializer = null;
Type cashType = ((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceStateType();
if (DataConstraintModel.typeList.isAncestorOf(cashType) || DataConstraintModel.typeTuple.isAncestorOf(cashType)) {
if (DataConstraintModel.typeList.isAncestorOf(cashType)) {
cashInitializer = "new " + cashType.getImplementationTypeName() + "()";
}
type.addField(new FieldDeclaration(cashType, srcName, cashInitializer));
}
// Declare the field to store the state in the type of each resource.
if (((StoreAttribute) rn.getAttribute()).isStored()) {
String initializer = "new " + rn.getIdentifierTemplate().getResourceStateType().getImplementationTypeName() + "()";
Type stateType = rn.getIdentifierTemplate().getResourceStateType();
if (!DataConstraintModel.typeList.isAncestorOf(stateType) && !DataConstraintModel.typeTuple.isAncestorOf(stateType))
initializer = null;
if (!DataConstraintModel.typeList.isAncestorOf(stateType)) initializer = null;
type.addField(new FieldDeclaration(stateType, rn.getIdentifierTemplate().getResourceName(), initializer));
}
// Declare the getter method to obtain the state in the type of each resource.
View
AlgebraicDataflowArchitectureModel/src/parser/Parser.java