From c077d425abd197963bd16adc9c8a5219b907c145 Mon Sep 17 00:00:00 2001 From: "Frank.R.Wu" Date: Tue, 22 Mar 2022 16:37:36 +0800 Subject: [PATCH] feat: update YJSCompiler compile getGlobal in all contracts --- .../java/org/bdware/sc/compiler/YJSCompiler.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/bdware/sc/compiler/YJSCompiler.java b/src/main/java/org/bdware/sc/compiler/YJSCompiler.java index a7daebd..82c203b 100644 --- a/src/main/java/org/bdware/sc/compiler/YJSCompiler.java +++ b/src/main/java/org/bdware/sc/compiler/YJSCompiler.java @@ -163,13 +163,14 @@ public class YJSCompiler { czb.put(preSubConName + ".yjs", preSubNode); LOGGER.info("--compile-- " + preSubConName); - String setGlobalName = cm.main.substring(0, cm.main.length() - 4) + "SetGlobal"; - String setGlobalContract = - "contract " + setGlobalName + "{ function setGlobal (_global) { Global = _global; }}"; - czb.put(setGlobalName + ".yjs", - compile(new ByteArrayInputStream(setGlobalContract.getBytes(StandardCharsets.UTF_8)), - setGlobalName + ".yjs")); - LOGGER.info("--compile-- " + setGlobalName); + String globalBeanName = cm.main.substring(0, cm.main.length() - 4) + "GlobalBean"; + String globalBeanContract = + "contract " + globalBeanName + "{ function setGlobal (_global) { Global = _global; }\n" + + " function getGlobal () { return Global; }}"; + czb.put(globalBeanName + ".yjs", + compile(new ByteArrayInputStream(globalBeanContract.getBytes(StandardCharsets.UTF_8)), + globalBeanName + ".yjs")); + LOGGER.info("--compile-- " + globalBeanName); return czb; }