public static String[] captureContructorAndResidual(char[] cs, int start, int offset) { int depth = 0; int end = start + offset; boolean inQuotes = false; for (int i = start; i < end; i++) { switch (cs[i]) { case '"': inQuotes = !inQuotes; break; case '(': depth++; break; case ')': if (!inQuotes) { if (1 == depth--) { return new String[]{createStringTrimmed(cs, start, ++i - start), createStringTrimmed(cs, i, end - i)}; } } } } return new String[]{new String(cs, start, offset)}; }
public static String[] captureContructorAndResidual(char[] cs, int start, int offset) { int depth = 0; int end = start + offset; boolean inQuotes = false; for (int i = start; i < end; i++) { switch (cs[i]) { case '"': inQuotes = !inQuotes; break; case '(': depth++; break; case ')': if (!inQuotes) { if (1 == depth--) { return new String[]{createStringTrimmed(cs, start, ++i - start), createStringTrimmed(cs, i, end - i)}; } } } } return new String[]{new String(cs, start, offset)}; }
public static String[] captureContructorAndResidual(char[] cs) { int depth = 0; for (int i = 0; i < cs.length; i++) { switch (cs[i]) { case '(': depth++; continue; case ')': if (1 == depth--) { return new String[]{new String(cs, 0, ++i), createStringTrimmed(cs, i, cs.length - i)}; } } } return new String[]{new String(cs)}; }
public WithNode(char[] expr, char[] block, int fields, ParserContext pCtx) { nestParm = createStringTrimmed(this.name = expr); this.block = block; if ((fields & COMPILE_IMMEDIATE) != 0) { pCtx.setBlockSymbols(true); egressType = (nestedStatement = (ExecutableStatement) subCompileExpression(nestParm.toCharArray(), pCtx)).getKnownEgressType(); withExpressions = compileWithExpressions(block, nestParm, egressType, pCtx); pCtx.setBlockSymbols(false); } }
public TypedVarNode(char[] expr, int start, int offset, int fields, Class type, ParserContext pCtx) { super(pCtx); this.egressType = type; this.fields = fields; this.expr = expr; this.start = start; this.offset = offset; int assignStart; if ((assignStart = find(this.expr = expr, start, offset, '=')) != -1) { checkNameSafety(name = createStringTrimmed(expr, start, assignStart - start)); this.offset -= (assignStart - start); this.start = assignStart + 1; if (((fields |= ASSIGN) & COMPILE_IMMEDIATE) != 0) { statement = (ExecutableStatement) subCompileExpression(expr, this.start, this.offset, pCtx); } } else { checkNameSafety(name = new String(expr, start, offset)); } if ((fields & COMPILE_IMMEDIATE) != 0) { Class x = pCtx.getVarOrInputType(name); if (x != null && x != Object.class && !x.isAssignableFrom(egressType)) { throw new RuntimeException("statically-typed variable already defined in scope: " + name); } pCtx.addVariable(name, egressType, false); } }
public TypedVarNode(char[] expr, int start, int offset, int fields, Class type, ParserContext pCtx) { super(pCtx); this.egressType = type; this.fields = fields; this.expr = expr; this.start = start; this.offset = offset; int assignStart; if ((assignStart = find(this.expr = expr, start, offset, '=')) != -1) { checkNameSafety(name = createStringTrimmed(expr, start, assignStart - start)); this.offset -= (assignStart - start); this.start = assignStart + 1; if (((fields |= ASSIGN) & COMPILE_IMMEDIATE) != 0) { statement = (ExecutableStatement) subCompileExpression(expr, this.start, this.offset, pCtx); } } else { checkNameSafety(name = new String(expr, start, offset)); } if ((fields & COMPILE_IMMEDIATE) != 0) { Class x = pCtx.getVarOrInputType(name); if (x != null && x != Object.class && !x.isAssignableFrom(egressType)) { throw new RuntimeException("statically-typed variable already defined in scope: " + name); } pCtx.addVariable(name, egressType, false); } }
private void handleCond(char[] condition, int start, int offset, int fields, ParserContext pCtx) { int cursor = start; int end = start + offset; while (cursor < end && condition[cursor] != ':') cursor++; if (cursor == end || condition[cursor] != ':') throw new CompileException("expected : in foreach", condition, cursor); int x; if ((x = (item = createStringTrimmed(condition, start, cursor - start)).indexOf(' ')) != -1) { String tk = new String(condition, start, x).trim(); try { itemType = ParseTools.findClass(null, tk, pCtx); item = new String(condition, start + x, (cursor - start) - x).trim(); } catch (ClassNotFoundException e) { throw new CompileException("cannot resolve identifier: " + tk, condition, start); } } // this.start = ++cursor; this.start = cursor + 1; this.offset = offset - (cursor - start) - 1; if ((fields & COMPILE_IMMEDIATE) != 0) { Class egress = (this.condition = (ExecutableStatement) subCompileExpression(expr, this.start, this.offset, pCtx)).getKnownEgressType(); if (itemType != null && egress.isArray()) { enforceTypeSafety(itemType, getBaseComponentType(this.condition.getKnownEgressType())); } else if (pCtx.isStrongTyping()) { determineIterType(egress); } } }
public ProtoVarNode(char[] expr, int start, int offset, int fields, Proto type, ParserContext pCtx) { super(pCtx); this.egressType = Proto.ProtoInstance.class; this.expr = expr; this.start = start; this.offset = offset; this.fields = fields; int assignStart; if ((assignStart = find(super.expr = expr, start, offset, '=')) != -1) { checkNameSafety(name = createStringTrimmed(expr, 0, assignStart)); if (((fields |= ASSIGN) & COMPILE_IMMEDIATE) != 0) { statement = (ExecutableStatement) subCompileExpression(expr, assignStart + 1, offset, pCtx); } } else { checkNameSafety(name = new String(expr, start, offset)); } if ((fields & COMPILE_IMMEDIATE) != 0) { pCtx.addVariable(name, egressType, true); } }
public AssignmentNode(char[] expr, int fields, ParserContext pCtx) { this.name = expr; int assignStart; if ((assignStart = find(expr, '=')) != -1) { this.varName = createStringTrimmed(expr, 0, assignStart); stmt = subset(expr, assignStart + 1); if ((fields & COMPILE_IMMEDIATE) != 0) { this.egressType = (statement = (ExecutableStatement) subCompileExpression(stmt, pCtx)).getKnownEgressType(); } if (col = ((endOfName = findFirst('[', indexTarget = this.varName.toCharArray())) > 0)) { if (((this.fields |= COLLECTION) & COMPILE_IMMEDIATE) != 0) { accExpr = (CompiledAccExpression) compileSetExpression(indexTarget, pCtx); } this.varName = new String(expr, 0, endOfName); index = new String(indexTarget, endOfName, indexTarget.length - endOfName); } checkNameSafety(this.varName); } else { checkNameSafety(this.varName = new String(expr)); } if ((fields & COMPILE_IMMEDIATE) != 0) { pCtx.addVariable(this.varName, egressType); } this.name = this.varName.toCharArray(); }
public ProtoVarNode(char[] expr, int start, int offset, int fields, Proto type, ParserContext pCtx) { super(pCtx); this.egressType = Proto.ProtoInstance.class; this.expr = expr; this.start = start; this.offset = offset; this.fields = fields; int assignStart; if ((assignStart = find(super.expr = expr, start, offset, '=')) != -1) { checkNameSafety(name = createStringTrimmed(expr, 0, assignStart)); if (((fields |= ASSIGN) & COMPILE_IMMEDIATE) != 0) { statement = (ExecutableStatement) subCompileExpression(expr, assignStart + 1, offset, pCtx); } } else { checkNameSafety(name = new String(expr, start, offset)); } if ((fields & COMPILE_IMMEDIATE) != 0) { pCtx.addVariable(name, egressType, true); } }
public WithNode(char[] expr, int start, int offset, int blockStart, int blockOffset, int fields, ParserContext pCtx) { super(pCtx); nestParm = createStringTrimmed(this.expr = expr, this.start = start, this.offset = offset); this.blockStart = blockStart; this.blockOffset = blockOffset; if ((fields & COMPILE_IMMEDIATE) != 0) { pCtx.setBlockSymbols(true); egressType = (compiledBlock = (ExecutableStatement) subCompileExpression(expr, start, offset, pCtx)).getKnownEgressType(); withExpressions = compileWithExpressions(expr, blockStart, blockOffset, nestParm, egressType, pCtx); pCtx.setBlockSymbols(false); } }
private void handleCond(char[] condition, int start, int offset, int fields, ParserContext pCtx) { int cursor = start; int end = start + offset; while (cursor < end && condition[cursor] != ':') cursor++; if (cursor == end || condition[cursor] != ':') throw new CompileException("expected : in foreach", condition, cursor); int x; if ((x = (item = createStringTrimmed(condition, start, cursor - start)).indexOf(' ')) != -1) { String tk = new String(condition, start, x).trim(); try { itemType = ParseTools.findClass(null, tk, pCtx); item = new String(condition, start + x, (cursor - start) - x).trim(); } catch (ClassNotFoundException e) { throw new CompileException("cannot resolve identifier: " + tk, condition, start); } } // this.start = ++cursor; this.start = cursor + 1; this.offset = offset - (cursor - start) - 1; if ((fields & COMPILE_IMMEDIATE) != 0) { Class egress = (this.condition = (ExecutableStatement) subCompileExpression(expr, this.start, this.offset, pCtx)).getKnownEgressType(); if (itemType != null && egress.isArray()) { enforceTypeSafety(itemType, getBaseComponentType(this.condition.getKnownEgressType())); } else if (pCtx.isStrongTyping()) { determineIterType(egress); } } }
private void handleCond(char[] condition, int fields, ParserContext pCtx) { int cursor = 0; while (cursor < condition.length && condition[cursor] != ':') cursor++; if (cursor == condition.length || condition[cursor] != ':') throw new CompileException("expected : in foreach"); int x; if ((x = (item = createStringTrimmed(condition, 0, cursor)).indexOf(' ')) != -1) { String tk = new String(condition, 0, x).trim(); try { itemType = ParseTools.findClass(null, tk, pCtx); item = new String(condition, x, cursor - x).trim(); } catch (ClassNotFoundException e) { throw new CompileException("cannot resolve identifier: " + tk); } } this.cond = subset(condition, ++cursor); if ((fields & COMPILE_IMMEDIATE) != 0) { Class egress = (this.condition = (ExecutableStatement) subCompileExpression(this.cond, pCtx)).getKnownEgressType(); if (itemType != null && egress.isArray()) { enforceTypeSafety(itemType, getBaseComponentType(this.condition.getKnownEgressType())); } else if (pCtx.isStrongTyping()) { determineIterType(egress); } } }
public WithNode(char[] expr, int start, int offset, int blockStart, int blockOffset, int fields, ParserContext pCtx) { super(pCtx); nestParm = createStringTrimmed(this.expr = expr, this.start = start, this.offset = offset); this.blockStart = blockStart; this.blockOffset = blockOffset; if ((fields & COMPILE_IMMEDIATE) != 0) { pCtx.setBlockSymbols(true); egressType = (compiledBlock = (ExecutableStatement) subCompileExpression(expr, start, offset, pCtx)).getKnownEgressType(); withExpressions = compileWithExpressions(expr, blockStart, blockOffset, nestParm, egressType, pCtx); pCtx.setBlockSymbols(false); } }
public DeepAssignmentNode(char[] expr, int fields, int operation, String name, ParserContext pCtx) { this.fields |= DEEP_PROPERTY | fields; this.name = expr; int mark; if (operation != -1) { this.egressType = ((statement = (ExecutableStatement) subCompileExpression(stmt = createShortFormOperativeAssignment(this.property = name, expr, operation), pCtx))).getKnownEgressType(); } else if ((mark = find(expr, '=')) != -1) { property = createStringTrimmed(expr, 0, mark); stmt = subset(expr, mark + 1); if ((fields & COMPILE_IMMEDIATE) != 0) { statement = (ExecutableStatement) subCompileExpression(stmt, pCtx); } } else { property = new String(expr); } if ((fields & COMPILE_IMMEDIATE) != 0) { acc = (CompiledAccExpression) compileSetExpression(property.toCharArray(), pCtx); } }
public ProtoVarNode(char[] expr, int fields, Proto type, ParserContext pCtx) { this.egressType = Proto.ProtoInstance.class; this.fields = fields; int assignStart; if ((assignStart = find(super.name = expr, '=')) != -1) { checkNameSafety(name = createStringTrimmed(expr, 0, assignStart)); if (((fields |= ASSIGN) & COMPILE_IMMEDIATE) != 0) { statement = (ExecutableStatement) subCompileExpression(stmt = subset(expr, assignStart + 1), pCtx); } else { stmt = subset(expr, assignStart + 1); } } else { checkNameSafety(name = new String(expr)); } if ((fields & COMPILE_IMMEDIATE) != 0) { pCtx.addVariable(name, egressType, true); } }
public TypedVarNode(char[] expr, int fields, Class type, ParserContext pCtx) { this.egressType = type; this.fields = fields; int assignStart; if ((assignStart = find(super.name = expr, '=')) != -1) { checkNameSafety(name = createStringTrimmed(expr, 0, assignStart)); if (((fields |= ASSIGN) & COMPILE_IMMEDIATE) != 0) { statement = (ExecutableStatement) subCompileExpression(stmt = subset(expr, assignStart + 1), pCtx); } else { stmt = subset(expr, assignStart + 1); } } else { checkNameSafety(name = new String(expr)); } if ((fields & COMPILE_IMMEDIATE) != 0) { pCtx.addVariable(name, egressType, true); } }
property = createStringTrimmed(expr, start, mark - start);
property = createStringTrimmed(expr, start, mark - start);
public IndexedAssignmentNode(char[] expr, int fields, int operation, String name, int register, ParserContext pCtx) { super.name = expr; this.register = register; int assignStart; if (operation != -1) { checkNameSafety(this.name = name); this.egressType = (statement = (ExecutableStatement) subCompileExpression(stmt = createShortFormOperativeAssignment(name, expr, operation), pCtx)).getKnownEgressType(); } else if ((assignStart = find(expr, '=')) != -1) { this.name = createStringTrimmed(expr, 0, assignStart); this.egressType = (statement = (ExecutableStatement) subCompileExpression(stmt = subset(expr, assignStart + 1), pCtx)) .getKnownEgressType(); if (col = ((endOfName = (short) findFirst('[', indexTarget = this.name.toCharArray())) > 0)) { if (((this.fields |= COLLECTION) & COMPILE_IMMEDIATE) != 0) { accExpr = (CompiledAccExpression) compileSetExpression(indexTarget, pCtx); } this.name = new String(expr, 0, endOfName); index = subset(indexTarget, endOfName, indexTarget.length - endOfName); } checkNameSafety(this.name); } else { checkNameSafety(this.name = new String(expr)); } if ((fields & COMPILE_IMMEDIATE) != 0) { pCtx.addVariable(name, egressType); } }