Package org.openquark.cal.internal.javamodel.JavaStatement

Examples of org.openquark.cal.internal.javamodel.JavaStatement.SwitchStatement.addCase()


            T arg) {
        SwitchStatement newSwitch = new SwitchStatement (
                (JavaExpression)switchStatement.getCondition().accept(this, arg));
       
        if (switchStatement.getDefaultStatement() != null) {
            newSwitch.addCase (new SwitchStatement.DefaultCase (
                    (JavaStatement)switchStatement.getDefaultStatement().accept(this, arg)));
        }
       
        List<IntCaseGroup> cases = switchStatement.getCaseGroups();
        for (int i = 0, n = cases.size(); i < n; ++i) {
View Full Code Here


                    (JavaStatement)switchStatement.getDefaultStatement().accept(this, arg)));
        }
       
        List<IntCaseGroup> cases = switchStatement.getCaseGroups();
        for (int i = 0, n = cases.size(); i < n; ++i) {
            newSwitch.addCase(
                    (SwitchStatement.SwitchCase)cases.get(i).accept(this, arg));
        }
       
        return newSwitch;
    }
View Full Code Here

                JavaStatement altStatement = genS_R(alt.getAltExpr(), variableContext);
                caseBlock.addStatement(variableContext.popJavaScope());
                caseBlock.addStatement(altStatement);

                if (alt.isDefaultAlt()) {
                    switchStatement.addCase(new SwitchStatement.DefaultCase(caseBlock));

                } else {
                    int[] caseLabels = new int[altTags.size()];
                    int index = 0;
                    for (final Object tag : altTags) {
View Full Code Here

                        caseLabels[index] = ((DataConstructor)tag).getOrdinal();
                        index++;
                    }

                    switchStatement.addCase(new SwitchStatement.IntCaseGroup(caseLabels, caseBlock));
                }

            } else {
                // The alts use variables.
View Full Code Here

                        // Compile the actual body of the alternate.
                        JavaStatement altStatement = genS_R(alt.getAltExpr(), variableContext);
                        caseBlock.addStatement(variableContext.popJavaScope());
                        caseBlock.addStatement(altStatement);

                        switchStatement.addCase(new SwitchStatement.IntCaseGroup(caseLabels, caseBlock));
                    }
                } else {
                    // Matching notation for switch alternate.
                    Map<FieldName, String> fieldNameToVarNameMap = ((SwitchAlt.Matching)alt).getFieldNameToVarNameMap();
View Full Code Here

                    // Compile the actual body of the alternate.
                    JavaStatement altStatement = genS_R(alt.getAltExpr(), variableContext);
                    caseBlock.addStatement(variableContext.popJavaScope());
                    caseBlock.addStatement(altStatement);

                    switchStatement.addCase(new SwitchStatement.IntCaseGroup(caseLabels, caseBlock));
                }
            }
        }

        // If no default case is provided, add case alternates for any missing data constructors.
View Full Code Here

            addMissingCases(intTagList, typeCons, switchStatement, eswitch);


            // Create a default default case.
            defaultCase = generateReturn(getBadSwitchIndexCall(eswitch.getErrorInfo()), variableContext);
            switchStatement.addCase (new SwitchStatement.DefaultCase(defaultCase));
        }

        return switchBlock;
    }
View Full Code Here

            JavaStatement altStatement = genS_R(alt.getAltExpr(), variableContext);
            caseBlock.addStatement(variableContext.popJavaScope());
            caseBlock.addStatement(altStatement);

            if (alt.isDefaultAlt()) {
                switchStatement.addCase(new SwitchStatement.DefaultCase(caseBlock));

            } else {
                List<Object> altTags = alt.getAltTags();
                int[] caseLabels = new int[altTags.size()];
View Full Code Here

                    caseLabels[index] = ((Integer)tag).intValue();
                    index++;
                }

                switchStatement.addCase(new SwitchStatement.IntCaseGroup(caseLabels, caseBlock));
            }
        }

        // Add case alternate for default case if missing.
        if (switchStatement.getDefaultStatement() == null) {
View Full Code Here

            //However, because cases on ints are also used by internal dictionary functions, and a few other situations
            //it could happen that this occurs because of an internal error.
            //todoBI encode enough information into Expression.Switch so that we know which case we're in.
            //todoBI pass the unhandled int value that occurred at runtime i.e. 2 in the above example, to the error message
            JavaStatement defaultCase = generateReturn(getUnhandledSwitchIndexForIntPatternCall(eswitch.getErrorInfo()), variableContext);
            switchStatement.addCase (new SwitchStatement.DefaultCase(defaultCase));
        }

        return switchBlock;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.