mirror of
https://gitee.com/BDWare/common
synced 2025-01-09 17:34:16 +00:00
add DoipOperation relevant update
This commit is contained in:
parent
611d25a044
commit
4dfca5a4a0
@ -1,6 +1,7 @@
|
||||
package org.bdware.sc.node;
|
||||
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.bdware.doip.codec.operations.BasicOperations;
|
||||
import org.bdware.sc.event.REvent.REventSemantics;
|
||||
|
||||
import java.util.*;
|
||||
@ -12,6 +13,7 @@ public class ContractNode {
|
||||
private final List<ClassNode> clzs;
|
||||
private final List<FunctionNode> functions;
|
||||
private final Map<String, FunctionNode> functionMap;
|
||||
private final Map<BasicOperations, FunctionNode> doipOperationsMap;
|
||||
private final Set<String> dependentContracts;
|
||||
public Map<String, REventSemantics> events;
|
||||
public Map<String, REventSemantics> logs;
|
||||
@ -38,6 +40,7 @@ public class ContractNode {
|
||||
permission = new ArrayList<>();
|
||||
instrumentBranch = false;
|
||||
dependentContracts = new HashSet<>();
|
||||
doipOperationsMap = new HashMap<>();
|
||||
}
|
||||
|
||||
public void addFunction(FunctionNode function) {
|
||||
@ -196,4 +199,25 @@ public class ContractNode {
|
||||
public void resetContractName(String name) {
|
||||
contractName = name;
|
||||
}
|
||||
|
||||
public void addDoipOperation(FunctionNode function) {
|
||||
doipOperationsMap.put(function.getDoipOperationInfo().operationType, function);
|
||||
}
|
||||
|
||||
public FunctionNode getDoipOperation(String action) {
|
||||
FunctionNode result = null;
|
||||
for (BasicOperations op : BasicOperations.values()) {
|
||||
if (op.toString().equals(action)) {
|
||||
result = doipOperationsMap.get(op);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result = doipOperationsMap.get(BasicOperations.Unknown);
|
||||
return result;
|
||||
}
|
||||
|
||||
public FunctionNode getDoipOperation(BasicOperations basicOperation) {
|
||||
return doipOperationsMap.get(basicOperation);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.bdware.sc.node;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import org.bdware.sc.bean.DoipOperationInfo;
|
||||
import org.bdware.sc.bean.JoinInfo;
|
||||
import org.bdware.sc.bean.RouteInfo;
|
||||
|
||||
@ -25,6 +26,7 @@ public class FunctionNode extends Script {
|
||||
private CostDetail cost;
|
||||
private RouteInfo routeInfo;
|
||||
private JoinInfo joinInfo;
|
||||
private DoipOperationInfo doipOperationInfo;
|
||||
private boolean isHandler;
|
||||
private boolean isConfidential;
|
||||
private boolean isHomomorphicEncrypt;
|
||||
@ -36,6 +38,14 @@ public class FunctionNode extends Script {
|
||||
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<>();
|
||||
|
@ -3,5 +3,6 @@ package org.bdware.sc.node;
|
||||
public enum YjsType {
|
||||
Oracle,
|
||||
Contract,
|
||||
DoipModule,
|
||||
Module
|
||||
}
|
||||
|
@ -72,7 +72,10 @@ public class ContractReader extends YJSParserBaseVisitor<ContractNode> {
|
||||
node.setYjsType(YjsType.Contract);
|
||||
} else if (null != contractDelcar.Module()) {
|
||||
node.setYjsType(YjsType.Module);
|
||||
} else if (null != contractDelcar.DoipModule()) {
|
||||
node.setYjsType(YjsType.DoipModule);
|
||||
}
|
||||
|
||||
if (null != contractDelcar.annotations())
|
||||
annotations = contractDelcar.annotations().annotation();
|
||||
for (AnnotationContext annotation : annotations) {
|
||||
|
20
src/main/entry/org/bdware/sc/bean/DoipOperationInfo.java
Normal file
20
src/main/entry/org/bdware/sc/bean/DoipOperationInfo.java
Normal file
@ -0,0 +1,20 @@
|
||||
package org.bdware.sc.bean;
|
||||
|
||||
import org.bdware.doip.codec.operations.BasicOperations;
|
||||
import org.bdware.sc.node.AnnotationNode;
|
||||
import org.bdware.sc.node.ContractNode;
|
||||
import org.bdware.sc.util.JsonUtil;
|
||||
|
||||
public class DoipOperationInfo {
|
||||
public BasicOperations operationType;
|
||||
|
||||
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);
|
||||
}
|
||||
System.out.println("[DoipOperationInfo] annotationNode:" + JsonUtil.toJson(annotationNode));
|
||||
return info;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user