/** * Deep clone statement to produce a new identical statement. * @return Deep clone */ public BranchingStatement clone() { BranchingStatement clone = new BranchingStatement(); clone.mode = mode; clone.label = label; return clone; }
public String toString() { return bs.toString(); }
final public BranchingStatement branchingStatement(ParseInfo info) throws ParseException { BranchingStatement breakStmt = new BranchingStatement(); Token mode = null; String label = null; throw new ParseException(); breakStmt.setMode(BranchingStatement.BranchingMode.valueOf(mode.image.toUpperCase())); breakStmt.setLabel(label); {if (true) return breakStmt;} throw new Error("Missing return statement in function");
@Override public void visit(BranchingStatement obj) { boolean matchedLabel = false; boolean inLoop = false; for (LanguageObject lo : stack) { if (lo instanceof LoopStatement || lo instanceof WhileStatement) { inLoop = true; if (obj.getLabel() == null) { break; } matchedLabel |= obj.getLabel().equalsIgnoreCase(((Labeled)lo).getLabel()); } else if (obj.getLabel() != null && lo instanceof Block && obj.getLabel().equalsIgnoreCase(((Block)lo).getLabel())) { matchedLabel = true; if (obj.getMode() != BranchingMode.LEAVE) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.invalid_label", obj.getLabel()), obj); //$NON-NLS-1$ } } } if (obj.getMode() != BranchingMode.LEAVE && !inLoop) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.no_loop"), obj); //$NON-NLS-1$ } if (obj.getLabel() != null && !matchedLabel) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.unknown_block_label", obj.getLabel()), obj); //$NON-NLS-1$ } }
@Test public void testContinueStatement1() throws Exception { BranchingStatement contStmt = new BranchingStatement(BranchingMode.CONTINUE); contStmt.setLabel("x"); helpStmtTest("continue x;", "CONTINUE x;", contStmt); //$NON-NLS-1$ //$NON-NLS-2$ }
final public BranchingStatement branchingStatement(ParseInfo info) throws ParseException { BranchingStatement breakStmt = new BranchingStatement(); Token mode = null; String label = null; throw new ParseException(); breakStmt.setMode(BranchingStatement.BranchingMode.valueOf(mode.image.toUpperCase())); breakStmt.setLabel(label); {if (true) return breakStmt;} throw new Error("Missing return statement in function");
@Override public void visit(BranchingStatement obj) { boolean matchedLabel = false; boolean inLoop = false; for (LanguageObject lo : stack) { if (lo instanceof LoopStatement || lo instanceof WhileStatement) { inLoop = true; if (obj.getLabel() == null) { break; } matchedLabel |= obj.getLabel().equalsIgnoreCase(((Labeled)lo).getLabel()); } else if (obj.getLabel() != null && lo instanceof Block && obj.getLabel().equalsIgnoreCase(((Block)lo).getLabel())) { matchedLabel = true; if (obj.getMode() != BranchingMode.LEAVE) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.invalid_label", obj.getLabel()), obj); //$NON-NLS-1$ } } } if (obj.getMode() != BranchingMode.LEAVE && !inLoop) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.no_loop"), obj); //$NON-NLS-1$ } if (obj.getLabel() != null && !matchedLabel) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.unknown_block_label", obj.getLabel()), obj); //$NON-NLS-1$ } }
@Test public void testWhileStatement1() throws Exception { ElementSymbol x = new ElementSymbol("x", false); //$NON-NLS-1$ Function f = new Function("+", new Expression[] { x, new Constant(new Integer(1)) }); //$NON-NLS-1$ Statement assignmentStmt = new AssignmentStatement(x, f); Block block = new Block(); block.setAtomic(true); block.setLabel("1y"); block.addStatement(assignmentStmt); BranchingStatement bs = new BranchingStatement(BranchingMode.CONTINUE); bs.setLabel("1y"); block.addStatement(bs); Criteria crit = new CompareCriteria(x, CompareCriteria.LT, new Constant(new Integer(100))); WhileStatement whileStmt = new WhileStatement(crit, block); helpStmtTest("WHILE (x < 100) \"1y\": BEGIN ATOMIC x=x+1; CONTINUE \"1y\"; END", //$NON-NLS-1$ "WHILE(x < 100)"+"\n"+ "\"1y\" : BEGIN ATOMIC"+"\n"+"x = (x + 1);\nCONTINUE \"1y\";" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ +"\n"+"END", whileStmt); //$NON-NLS-1$ //$NON-NLS-2$ }
final public BranchingStatement branchingStatement(ParseInfo info) throws ParseException { BranchingStatement breakStmt = new BranchingStatement(); Token mode = null; String label = null; throw new ParseException(); breakStmt.setMode(BranchingStatement.BranchingMode.valueOf(mode.image.toUpperCase())); breakStmt.setLabel(label); {if (true) return breakStmt;} throw new Error("Missing return statement in function");
@Override public void visit(BranchingStatement obj) { boolean matchedLabel = false; boolean inLoop = false; for (LanguageObject lo : stack) { if (lo instanceof LoopStatement || lo instanceof WhileStatement) { inLoop = true; if (obj.getLabel() == null) { break; } matchedLabel |= obj.getLabel().equalsIgnoreCase(((Labeled)lo).getLabel()); } else if (obj.getLabel() != null && lo instanceof Block && obj.getLabel().equalsIgnoreCase(((Block)lo).getLabel())) { matchedLabel = true; if (obj.getMode() != BranchingMode.LEAVE) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.invalid_label", obj.getLabel()), obj); //$NON-NLS-1$ } } } if (obj.getMode() != BranchingMode.LEAVE && !inLoop) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.no_loop"), obj); //$NON-NLS-1$ } if (obj.getLabel() != null && !matchedLabel) { handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.unknown_block_label", obj.getLabel()), obj); //$NON-NLS-1$ } }
/** * Deep clone statement to produce a new identical statement. * @return Deep clone */ public BranchingStatement clone() { BranchingStatement clone = new BranchingStatement(); clone.mode = mode; clone.label = label; return clone; }
public String toString() { return bs.toString(); }
public void process(ProcedurePlan env) throws TeiidComponentException { Program parentProgram = env.peek(); //find the parent program that contains the loop/while instruction while(true){ if (bs.getMode() == BranchingMode.LEAVE && bs.getLabel().equalsIgnoreCase(parentProgram.getLabel())) { env.pop(true); break; } if(parentProgram.getCurrentInstruction() instanceof RepeatedInstruction){ if (bs.getLabel() == null) { break; } RepeatedInstruction ri = (RepeatedInstruction)parentProgram.getCurrentInstruction(); if (bs.getLabel().equalsIgnoreCase(ri.getLabel())) { break; } } env.pop(true); parentProgram = env.peek(); } if (bs.getMode() != BranchingMode.CONTINUE) { env.incrementProgramCounter(); } }
/** * Deep clone statement to produce a new identical statement. * @return Deep clone */ public BranchingStatement clone() { BranchingStatement clone = new BranchingStatement(); clone.mode = mode; clone.label = label; return clone; }
public String toString() { return bs.toString(); }
public void process(ProcedurePlan env) throws TeiidComponentException { Program parentProgram = env.peek(); //find the parent program that contains the loop/while instruction while(true){ if (bs.getMode() == BranchingMode.LEAVE && bs.getLabel().equalsIgnoreCase(parentProgram.getLabel())) { env.pop(true); break; } if(parentProgram.getCurrentInstruction() instanceof RepeatedInstruction){ if (bs.getLabel() == null) { break; } RepeatedInstruction ri = (RepeatedInstruction)parentProgram.getCurrentInstruction(); if (bs.getLabel().equalsIgnoreCase(ri.getLabel())) { break; } } env.pop(true); parentProgram = env.peek(); } if (bs.getMode() != BranchingMode.CONTINUE) { env.incrementProgramCounter(); } }
public static final BranchingStatement sample1() { return new BranchingStatement(); }
public PlanNode getDescriptionProperties() { return new PlanNode(bs.toString()); }
@Override public void visit( BranchingStatement obj ) { switch (obj.getMode()) { case CONTINUE: append(CONTINUE); break; case BREAK: append(BREAK); break; case LEAVE: append(LEAVE); break; } if (obj.getLabel() != null) { append(SPACE); outputDisplayName(obj.getLabel()); } append(";"); //$NON-NLS-1$ }
public static final BranchingStatement sample2() { return new BranchingStatement(); }