finish the draft version

This commit is contained in:
haoeliu@foxmail.com 2022-11-27 18:58:34 +08:00
parent 07c8f40059
commit a4bc017a15
3 changed files with 43 additions and 12 deletions

View File

@ -47,9 +47,11 @@ public class ContractNode {
}
public void updateFunctionMap(String oldFunctionName, String newFunctionName) {
FunctionNode fn = functionMap.get(oldFunctionName);
functionMap.remove(oldFunctionName);
functionMap.put(newFunctionName, fn);
FunctionNode fn = functionMap.getOrDefault(oldFunctionName, null);
if(fn != null) {
functionMap.remove(oldFunctionName);
functionMap.put(newFunctionName, fn);
}
}
public void addClass(ClassNode clzNode) {

View File

@ -32,20 +32,13 @@ public class FunctionNode extends Script {
private boolean isHomomorphicEncrypt;
private boolean isHomomorphicDecrypt;
private boolean isView;
private boolean isDoipOperation;
private String keyManagerID;
private String secretID;
private JsonElement homoEncryptConf;
private JsonElement homoDecryptConf;
public transient Class compiledClazz;
public DoipOperationInfo getDoipOperationInfo() {
return doipOperationInfo;
}
public void setDoipOperationInfo(DoipOperationInfo doipOperationInfo) {
this.doipOperationInfo = doipOperationInfo;
}
public FunctionNode(String name, String fileName) {
this.functionName = name;
this.stmts = new ArrayList<>();
@ -68,6 +61,24 @@ public class FunctionNode extends Script {
afterInvoke = new ArrayList<>();
}
public DoipOperationInfo getDoipOperationInfo() {
return doipOperationInfo;
}
public void setDoipOperationInfo(DoipOperationInfo doipOperationInfo) {
this.doipOperationInfo = doipOperationInfo;
}
public void setIsDoipOperation(boolean doipOperation) {
isDoipOperation = doipOperation;
}
public boolean isDoipOperation() {
return isDoipOperation;
}
public Set<String> getDependentFunctions() {
return dependentFunctions;
}

View File

@ -6,13 +6,31 @@ import org.bdware.sc.node.ContractNode;
import org.bdware.sc.util.JsonUtil;
public class DoipOperationInfo {
public BasicOperations operationType;
public String operationType;
public String operationName;
public BasicOperations operation;
// todo 对于extension进行特别处理getArg() == 2就行这里合理吗参考RouteInfo貌似合理
public static DoipOperationInfo create(AnnotationNode annotationNode, ContractNode contractNode) {
DoipOperationInfo info = new DoipOperationInfo();
if (annotationNode.getArgs().size() == 1) {
String str = annotationNode.getArgs().get(0);
info = JsonUtil.fromJson(str, DoipOperationInfo.class);
// according to operationType to find operation and fill the corresponding fields
String opStr = info.operationType;
for (BasicOperations op : BasicOperations.values()) {
if (op.toString().equals(opStr)) {
info.operation = op;
}
}
if(info.operation == null) info.operation = BasicOperations.Unknown;
// If operation is not Extension, set the operationName directly from operation
if(info.operation != BasicOperations.Extension) {
info.operationName = info.operation.getName();
}
}
System.out.println("[DoipOperationInfo] annotationNode:" + JsonUtil.toJson(annotationNode));
return info;