diff --git a/src/main/base/org/bdware/sc/node/ContractNode.java b/src/main/base/org/bdware/sc/node/ContractNode.java index e4bc5ab..8d72277 100644 --- a/src/main/base/org/bdware/sc/node/ContractNode.java +++ b/src/main/base/org/bdware/sc/node/ContractNode.java @@ -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) { diff --git a/src/main/base/org/bdware/sc/node/FunctionNode.java b/src/main/base/org/bdware/sc/node/FunctionNode.java index f1646db..d7a8e54 100644 --- a/src/main/base/org/bdware/sc/node/FunctionNode.java +++ b/src/main/base/org/bdware/sc/node/FunctionNode.java @@ -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 getDependentFunctions() { return dependentFunctions; } diff --git a/src/main/entry/org/bdware/sc/bean/DoipOperationInfo.java b/src/main/entry/org/bdware/sc/bean/DoipOperationInfo.java index fb0b011..72f6bdd 100644 --- a/src/main/entry/org/bdware/sc/bean/DoipOperationInfo.java +++ b/src/main/entry/org/bdware/sc/bean/DoipOperationInfo.java @@ -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;