support interface

This commit is contained in:
CaiHQ 2023-07-24 12:33:54 +08:00
parent 7e8076e075
commit eb91d17982
5 changed files with 18 additions and 13 deletions

View File

@ -14,6 +14,7 @@ public abstract class AnnotationProcessor {
FunctionNode functionNode) throws Exception { FunctionNode functionNode) throws Exception {
return; return;
} }
public void processInterface(AnnotationNode anno, ContractNode contractNode, public void processInterface(AnnotationNode anno, ContractNode contractNode,
InterfaceNode functionNode) throws Exception { InterfaceNode functionNode) throws Exception {
return; return;

View File

@ -34,8 +34,7 @@ public class YJSCompiler {
ContractNode contract; ContractNode contract;
private static final Logger LOGGER = LogManager.getLogger(YJSCompiler.class); private static final Logger LOGGER = LogManager.getLogger(YJSCompiler.class);
public YJSCompiler() { public YJSCompiler() {}
}
public static ScriptFunction compileWithGlobal(Source source, Global global, Context context) { public static ScriptFunction compileWithGlobal(Source source, Global global, Context context) {
Global oldGlobal = Context.getGlobal(); Global oldGlobal = Context.getGlobal();
@ -140,7 +139,8 @@ public class YJSCompiler {
String cnPath = entry.getName(); String cnPath = entry.getName();
int i = cnPath.lastIndexOf("/"); int i = cnPath.lastIndexOf("/");
String cnDir = ""; String cnDir = "";
if (i != -1) cnDir = cnPath.substring(0, i); if (i != -1)
cnDir = cnPath.substring(0, i);
czb.put(str, cn); czb.put(str, cn);
for (ImportNode in : cn.getImports()) { for (ImportNode in : cn.getImports()) {
String path = in.getPath(); String path = in.getPath();
@ -157,7 +157,8 @@ public class YJSCompiler {
else { else {
// TODO parse manifest.json first? // TODO parse manifest.json first?
for (String entry : allEntries) for (String entry : allEntries)
if (!czb.containsPath(entry) && entry.startsWith(str) && entry.endsWith(".yjs")) { if (!czb.containsPath(entry) && entry.startsWith(str)
&& entry.endsWith(".yjs")) {
toParse.add(entry); toParse.add(entry);
} }
} }

View File

@ -18,6 +18,7 @@ public class DOOP extends AnnotationProcessor {
functionNode.setIsDoipOperation(true); functionNode.setIsDoipOperation(true);
functionNode.setDoipOperationInfo(DoipOperationInfo.create(anno, contractNode)); functionNode.setDoipOperationInfo(DoipOperationInfo.create(anno, contractNode));
} }
@Override @Override
public void processInterface(AnnotationNode anno, ContractNode contractNode, public void processInterface(AnnotationNode anno, ContractNode contractNode,
InterfaceNode interfaceNode) throws Exception { InterfaceNode interfaceNode) throws Exception {

View File

@ -15,6 +15,7 @@ public class Join extends AnnotationProcessor {
// 增加标记在ContractNode中记录Join相关的函数和Join规则 // 增加标记在ContractNode中记录Join相关的函数和Join规则
functionNode.setJoinInfo(JoinInfo.create(anno, contractNode)); functionNode.setJoinInfo(JoinInfo.create(anno, contractNode));
} }
@Override @Override
public void processInterface(AnnotationNode anno, ContractNode contractNode, public void processInterface(AnnotationNode anno, ContractNode contractNode,
InterfaceNode interfaceNode) { InterfaceNode interfaceNode) {

View File

@ -13,6 +13,7 @@ public class Route extends AnnotationProcessor {
FunctionNode functionNode) { FunctionNode functionNode) {
functionNode.setRouteInfo(RouteInfo.create(anno, contractNode)); functionNode.setRouteInfo(RouteInfo.create(anno, contractNode));
} }
@Override @Override
public void processInterface(AnnotationNode anno, ContractNode contractNode, public void processInterface(AnnotationNode anno, ContractNode contractNode,
InterfaceNode interfaceNode) { InterfaceNode interfaceNode) {