コンストラクタ関係の作成中
1 parent d175f6b commit c1c57a4f695f497586802d8a39dc9995de65ccbd
yoichiro authored on 27 Apr 2020
Showing 3 changed files
View
37
AlgebraicDataflowArchitectureModel/src/algorithms/CodeGenerator.java
+ ((ResourceNode) re.getDestination()).getIdentifierTemplate().getResourceName().substring(1);
if (((PushPullAttribute) re.getAttribute()).getOptions().get(0) == PushPullValue.PUSH) {
type.addField(new FieldDeclaration(new Type(rename, rename),
((ResourceNode) re.getDestination()).getIdentifierTemplate().getResourceName()));
type.addConstructor(new VariableDeclaration(new Type(rename, rename),((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceName()));
type.addConstructors(new VariableDeclaration(new Type(rename, rename),((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceName()));
}
}
for (Edge e : rn.getInEdges()) {
ResourceDependency re = (ResourceDependency) e;
+ ((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceName().substring(1);
if (((PushPullAttribute) re.getAttribute()).getOptions().get(0) != PushPullValue.PUSH) {
type.addField(new FieldDeclaration(new Type(rename, rename),
((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceName()));
type.addConstructor(new VariableDeclaration(new Type(rename, rename),((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceName()));
type.addConstructors(new VariableDeclaration(new Type(rename, rename),((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceName()));
}
}
if (((StoreAttribute) rn.getAttribute()).isStored())
type.addField(new FieldDeclaration(DataConstraintModel.typeInt,
for (TypeDeclaration type : codeTree) {
codes.add("public class " + type.getTypeName() + "{");
for (FieldDeclaration field : type.getFields()) {
if(type.getTypeName() != "Main") {
codes.add("\t" + field.getType().getImplementationTypeName() + " " + field.getName() + " = null;");
codes.add("\t" + "private " + field.getType().getImplementationTypeName() + " " + field.getName() + ";");
}else {
codes.add("\t" + field.getType().getImplementationTypeName() + " " + field.getName() + " = new " + field.getType().getTypeName() + "(" + ");");
String cons = "\t" + "private " + field.getType().getImplementationTypeName() + " " + field.getName() + " = new " + field.getType().getTypeName() + "(";
for(VariableDeclaration constructor:type.getConstructors()) {
cons += constructor.getName() + ",";
}
if(!type.getConstructors().isEmpty()) cons = cons.substring(0, cons.length() - 1);
cons += ");";
codes.add(cons);
}
}
codes.add("");
if (type.getTypeName() != "Main") {
String cons = "\t" + type.getTypeName() + "(";
for(VariableDeclaration constructor:type.getConstructor()) {
String cons = "\t" + "public " + type.getTypeName() + "(";
for(VariableDeclaration constructor:type.getConstructors()) {
cons += constructor.getType().getTypeName() + " " + constructor.getName() + ",";
}
cons = cons.substring(0, cons.length() - 1);
if(!type.getConstructors().isEmpty()) cons = cons.substring(0, cons.length() - 1);
cons += ");";
codes.add(cons);
for (FieldDeclaration field : type.getFields()) {
if(type.getTypeName().toLowerCase() != field.getName()) codes.add("\t\t" + "this." + field.getName() + " = " + field.getName());
for(VariableDeclaration vari:type.getConstructors()) {
if(field.getType().getTypeName().equals(vari.getType().getTypeName())) {
codes.add("\t\t" + "this." + field.getName() + " = " + field.getName());
}
}
}
codes.add("\t" + "}");
}
for (MethodDeclaration method : type.getMethods()) {
codes.add("\t" + "}");
codes.add("");
}
codes.add("}");
codes.add("");
}
return codes;
}
 
View
22
AlgebraicDataflowArchitectureModel/src/code/ast/ConstructorDeclaration.java 0 → 100644
package code.ast;
 
import models.algebra.Type;
 
public class ConstructorDeclaration extends FieldDeclaration {
private VariableDeclaration constructor;
 
public ConstructorDeclaration(Type type, String fieldName,VariableDeclaration constructor) {
super(type, fieldName);
this.setConstructor(constructor);
}
 
public VariableDeclaration getConstructor() {
return constructor;
}
 
public void setConstructor(VariableDeclaration constructor) {
this.constructor = constructor;
}
 
}
View
AlgebraicDataflowArchitectureModel/src/code/ast/TypeDeclaration.java