赞
踩
public Object execute(String expressString, IExpressContext<String, Object> context, List<String> errorList, boolean isCache, boolean isTrace, Log log) throws Exception { InstructionSet parseResult; if (isCache) { parseResult = expressInstructionSetCache.get(expressString); if (parseResult == null) { synchronized (expressInstructionSetCache) { parseResult = expressInstructionSetCache.get(expressString); if (parseResult == null) { parseResult = this.parseInstructionSet(expressString); expressInstructionSetCache.put(expressString, parseResult); } } } } else { parseResult = this.parseInstructionSet(expressString); } return executeReentrant(parseResult, context, errorList, isTrace, log); } private Object executeReentrant(InstructionSet sets, IExpressContext<String, Object> iExpressContext, List<String> errorList, boolean isTrace, Log log) throws Exception { try { int reentrantCount = threadReentrantCount.get() + 1; threadReentrantCount.set(reentrantCount); return reentrantCount > 1 ? // 线程重入 InstructionSetRunner.execute(this, sets, this.loader, iExpressContext, errorList, isTrace, false, true, log, false) : InstructionSetRunner.executeOuter(this, sets, this.loader, iExpressContext, errorList, isTrace, false, log, false); } finally { threadReentrantCount.set(threadReentrantCount.get() - 1); } }
public InstructionSet getInstructionSetFromLocalCache(String expressString) throws Exception { InstructionSet parseResult = expressInstructionSetCache.get(expressString); if (parseResult == null) { synchronized (expressInstructionSetCache) { parseResult = expressInstructionSetCache.get(expressString); if (parseResult == null) { parseResult = this.parseInstructionSet(expressString); expressInstructionSetCache.put(expressString, parseResult); } } } return parseResult; } public InstructionSet createInstructionSet(ExpressNode root, String type) throws Exception { InstructionSet result = new InstructionSet(type); createInstructionSet(root, result); return result; } public void createInstructionSet(ExpressNode root, InstructionSet result) throws Exception { Stack<ForRelBreakContinue> forStack = new Stack<>(); createInstructionSetPrivate(result, forStack, root, true); if (!forStack.isEmpty()) { throw new QLCompileException("For处理错误"); } } public boolean createInstructionSetPrivate(InstructionSet result, Stack<ForRelBreakContinue> forStack, ExpressNode node, boolean isRoot) throws Exception { InstructionFactory factory = InstructionFactory.getInstructionFactory(node.getInstructionFactory()); return factory.createInstruction(this, result, forStack, node, isRoot); }
public boolean checkSyntax(String text, boolean mockRemoteJavaClass, List<String> remoteJavaClassNames) { try { Map<String, String> selfDefineClass = new HashMap<>(); for (ExportItem item : this.loader.getExportInfo()) { if (item.getType().equals(InstructionSet.TYPE_CLASS)) { selfDefineClass.put(item.getName(), item.getName()); } } Word[] words = this.parse.splitWords(text, isTrace, selfDefineClass); ExpressNode root = this.parse.parse(this.rootExpressPackage, words, text, isTrace, selfDefineClass, mockRemoteJavaClass); InstructionSet result = createInstructionSet(root, "main"); if (this.isTrace && log.isDebugEnabled()) { log.debug(result); } if (mockRemoteJavaClass && remoteJavaClassNames != null) { remoteJavaClassNames.addAll(Arrays.asList(result.getVirClasses())); } return true; } catch (Exception e) { log.error("checkSyntax has Exception", e); return false; } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。