Search in sources :

Example 6 with StatementBlock

use of org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock in project titan.EclipsePlug-ins by eclipse.

the class AltGuards method generateCodeAlt.

/**
 * Generate code for an alt
 *
 * @param aData the structure to put imports into and get temporal variable names from.
 * @param source the source code generated
 */
public void generateCodeAlt(final JavaGenData aData, final StringBuilder source) {
    aData.addBuiltinTypeImport("TitanAlt_Status");
    boolean labelNeeded = hasRepeat;
    boolean hasElseBranch = false;
    for (int i = 0; i < altGuards.size(); i++) {
        final AltGuard altGuard = altGuards.get(i);
        switch(altGuard.getType()) {
            case AG_OP:
                if (((Operation_Altguard) altGuard).getGuardStatement().canRepeat()) {
                    labelNeeded = true;
                }
                break;
            case AG_REF:
            case AG_INVOKE:
                labelNeeded = true;
                break;
            case AG_ELSE:
                hasElseBranch = true;
                break;
            default:
                ErrorReporter.INTERNAL_ERROR("unknown altguard type encountered `" + getFullName() + "''");
                return;
        }
        if (hasElseBranch) {
            break;
        }
    }
    // if there is no [else] branch the defaults may return ALT_REPEAT
    if (!hasElseBranch) {
        labelNeeded = true;
    }
    // opening bracket of the statement block
    label = aData.getTemporaryVariableName();
    if (labelNeeded) {
        source.append(label).append(":\n");
    }
    source.append("for ( ; ; ) {\n");
    // temporary variables used for caching of status codes
    for (int i = 0; i < altGuards.size(); i++) {
        final AltGuard altGuard = altGuards.get(i);
        if (altGuard.getType().equals(altguard_type.AG_ELSE)) {
            break;
        }
        source.append(MessageFormat.format("TitanAlt_Status {0}_alt_flag_{1} = ", label, i));
        if (altGuard.getGuardExpression() == null) {
            source.append("TitanAlt_Status.ALT_MAYBE");
        } else {
            source.append("TitanAlt_Status.ALT_UNCHECKED");
        }
        source.append(";\n");
    }
    if (!hasElseBranch) {
        source.append(MessageFormat.format("TitanAlt_Status {0}_default_flag = TitanAlt_Status.ALT_MAYBE;\n", label));
    }
    // the first snapshot is taken in non-blocking mode
    aData.addCommonLibraryImport("TTCN_Snapshot");
    source.append("TTCN_Snapshot.takeNew(false);\n");
    // and opening infinite for() loop
    source.append("for ( ; ; ) {\n");
    for (int i = 0; i < altGuards.size(); i++) {
        final AltGuard altGuard = altGuards.get(i);
        final altguard_type altGuardType = altGuard.getType();
        if (altGuardType.equals(altguard_type.AG_ELSE)) {
            source.append("TTCN_Snapshot.elseBranchReached();\n");
            StatementBlock block = altGuard.getStatementBlock();
            if (block.getSize() > 0) {
                source.append("{\n");
                // FIXME handle debugger
                block.generateCode(aData, source);
                source.append("}\n");
            }
            if (block.hasReturn(CompilationTimeStamp.getBaseTimestamp()) != ReturnStatus_type.RS_YES) {
                source.append("break;\n");
            }
            // do not generate code for further branches
            break;
        } else {
            final IValue guardExpression = altGuard.getGuardExpression();
            if (guardExpression != null) {
                source.append(MessageFormat.format("if ({0}_alt_flag_{1} == TitanAlt_Status.ALT_UNCHECKED) '{'\n", label, i));
                guardExpression.getLocation().update_location_object(aData, source);
                final ExpressionStruct expression = new ExpressionStruct();
                guardExpression.generateCodeExpression(aData, expression, true);
                source.append(expression.preamble);
                source.append(MessageFormat.format("if(TitanBoolean.getNative({0})) '{'\n", expression.expression));
                source.append(MessageFormat.format("{0}_alt_flag_{1} = TitanAlt_Status.ALT_MAYBE;\n", label, i));
                source.append("} else {\n");
                source.append(MessageFormat.format("{0}_alt_flag_{1} = TitanAlt_Status.ALT_NO;\n", label, i));
                source.append("}\n");
                source.append("}\n");
            }
            source.append(MessageFormat.format("if ({0}_alt_flag_{1} == TitanAlt_Status.ALT_MAYBE) '{'\n", label, i));
            boolean canRepeat = false;
            final ExpressionStruct expression = new ExpressionStruct();
            expression.expression.append(MessageFormat.format("{0}_alt_flag_{1} = ", label, i));
            switch(altGuardType) {
                case AG_OP:
                    {
                        // the guard operation is a receiving statement
                        final Statement statement = ((Operation_Altguard) altGuard).getGuardStatement();
                        altGuard.getLocation().update_location_object(aData, source);
                        statement.generateCodeExpression(aData, expression);
                        canRepeat = statement.canRepeat();
                    }
                    break;
                case AG_REF:
                    {
                        // the guard operation is an altstep instance
                        final Reference reference = ((Referenced_Altguard) altGuard).getGuardReference();
                        altGuard.getLocation().update_location_object(aData, source);
                        final Assignment altstep = reference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
                        expression.expression.append(MessageFormat.format("{0}_instance(", altstep.getGenNameFromScope(aData, source, myScope, "")));
                        final ISubReference subreference = reference.getSubreferences().get(0);
                        ((ParameterisedSubReference) subreference).getActualParameters().generateCodeAlias(aData, expression);
                        source.append(')');
                        canRepeat = true;
                    }
                    break;
                case AG_INVOKE:
                    {
                        // the guard operation is an altstep invocation
                        altGuard.getLocation().update_location_object(aData, source);
                        ((Invoke_Altguard) altGuard).generateCodeInvokeInstance(aData, expression);
                        canRepeat = true;
                    }
                    break;
                default:
                    ErrorReporter.INTERNAL_ERROR("unknown altguard type encountered `" + getFullName() + "''");
                    return;
            }
            expression.mergeExpression(source);
            if (canRepeat) {
                source.append(MessageFormat.format("if ({0}_alt_flag_{1} == TitanAlt_Status.ALT_REPEAT) continue {2};\n", label, i, label));
            }
            if (altGuardType.equals(altguard_type.AG_REF) || altGuardType.equals(altguard_type.AG_INVOKE)) {
                source.append(MessageFormat.format("if ({0}_alt_flag_{1} == TitanAlt_Status.ALT_BREAK) break;\n", label, i));
            }
            // execution of statement block if the guard was successful
            source.append(MessageFormat.format("if ({0}_alt_flag_{1} == TitanAlt_Status.ALT_YES) ", label, i));
            final StatementBlock block = altGuard.getStatementBlock();
            if (block != null && block.getSize() > 0) {
                source.append("{\n");
                // TODO handle debugger
                block.generateCode(aData, source);
                if (!ReturnStatus_type.RS_YES.equals(block.hasReturn(CompilationTimeStamp.getBaseTimestamp()))) {
                    source.append("break;\n");
                }
                source.append("}\n");
            } else {
                source.append("break;\n");
            }
            source.append("}\n");
        }
    }
    if (!hasElseBranch) {
        aData.addCommonLibraryImport("TTCN_Default");
        source.append(MessageFormat.format("if ({0}_default_flag == TitanAlt_Status.ALT_MAYBE) '{'\n", label));
        source.append(MessageFormat.format("{0}_default_flag = TTCN_Default.tryAltsteps();\n", label));
        source.append(MessageFormat.format("if ({0}_default_flag == TitanAlt_Status.ALT_YES || {0}_default_flag == TitanAlt_Status.ALT_BREAK) '{'\n", label));
        source.append("break;\n");
        source.append(MessageFormat.format("} else if({0}_default_flag == TitanAlt_Status.ALT_REPEAT) '{'\n", label));
        source.append(MessageFormat.format("continue {0};\n", label));
        source.append("}\n");
        source.append("}\n");
        getLocation().update_location_object(aData, source);
        // error handling and taking the next snapshot in blocking mode
        source.append("if ( ");
        for (int i = 0; i < altGuards.size(); i++) {
            source.append(MessageFormat.format("{0}_alt_flag_{1} == TitanAlt_Status.ALT_NO &&", label, i));
        }
        source.append(MessageFormat.format("{0}_default_flag == TitanAlt_Status.ALT_NO) '{'\n", label));
        source.append("throw new TtcnError(\"None of the branches can be chosen in the alt statement");
        // TODO translate_string
        if (location != null && location.getFile() != null) {
            source.append(MessageFormat.format("in file {0} at line {1}", location.getFile().getName(), location.getLine()));
        }
        source.append("\");\n");
        source.append("}\n");
        source.append("TTCN_Snapshot.takeNew(true);\n");
    }
    source.append("}\n");
    source.append("break;\n");
    source.append("}\n");
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) ISubReference(org.eclipse.titan.designer.AST.ISubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) IValue(org.eclipse.titan.designer.AST.IValue) AltGuard.altguard_type(org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard.altguard_type) Reference(org.eclipse.titan.designer.AST.Reference) ISubReference(org.eclipse.titan.designer.AST.ISubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)

Example 7 with StatementBlock

use of org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock in project titan.EclipsePlug-ins by eclipse.

the class AltGuards method generateCodeCallBody.

/**
 * Generate code for an altstep (as the body of a call statement)
 *
 * @param aData the structure to put imports into and get temporal variable names from.
 * @param source the source code generated
 * @param tempId temporary id used as prefix of local variables
 * @param inInterleave is it used in interleave?
 */
public void generateCodeCallBody(final JavaGenData aData, final StringBuilder source, final String tempId, final boolean inInterleave) {
    if (hasRepeat) {
        source.append(MessageFormat.format("{0}:", tempId));
    }
    // temporary variables used for caching of status codes
    for (int i = 0; i < altGuards.size(); i++) {
        final AltGuard altGuard = altGuards.get(i);
        source.append(MessageFormat.format("TitanAlt_Status {0}_alt_flag_{1} = ", tempId, i));
        if (altGuard.getGuardExpression() == null) {
            source.append("TitanAlt_Status.ALT_MAYBE");
        } else {
            source.append("TitanAlt_Status.ALT_UNCHECKED");
        }
        source.append(";\n");
    }
    getLocation().update_location_object(aData, source);
    // the first snapshot is taken in non-blocking mode
    // and opening infinite for() loop
    // the first snapshot is taken in non-blocking mode
    aData.addCommonLibraryImport("TTCN_Snapshot");
    source.append("TTCN_Snapshot.takeNew(false);\n");
    // and opening infinite for() loop
    source.append("for ( ; ; ) {\n");
    for (int i = 0; i < altGuards.size(); i++) {
        final AltGuard altGuard = altGuards.get(i);
        if (!(altGuard instanceof Operation_Altguard)) {
            // FATAL ERROR
            continue;
        }
        final IValue guardExpression = altGuard.getGuardExpression();
        if (guardExpression != null) {
            source.append(MessageFormat.format("if ( {0}_alt_flag_{1} == TitanAlt_Status.ALT_UNCHECKED) '{'\n", tempId, i));
            guardExpression.getLocation().update_location_object(aData, source);
            final ExpressionStruct expression = new ExpressionStruct();
            guardExpression.generateCodeExpression(aData, expression, true);
            source.append(expression.preamble);
            source.append(MessageFormat.format("if (TitanBoolean.getNative({0})) '{'\n", expression.expression));
            source.append(MessageFormat.format("{0}_alt_flag_{1} = TitanAlt_Status.ALT_MAYBE;\n", tempId, i));
            source.append("} else {\n");
            source.append(MessageFormat.format("{0}_alt_flag_{1} = TitanAlt_Status.ALT_NO;\n", tempId, i));
            source.append("}\n");
            source.append(expression.postamble);
            source.append("}\n");
        }
        // evaluation of guard operation
        source.append(MessageFormat.format("if ( {0}_alt_flag_{1} == TitanAlt_Status.ALT_MAYBE) '{'\n", tempId, i));
        final ExpressionStruct expression = new ExpressionStruct();
        expression.expression.append(MessageFormat.format("{0}_alt_flag_{1} = ", tempId, i));
        final Statement statement = ((Operation_Altguard) altGuard).getGuardStatement();
        statement.getLocation().update_location_object(aData, source);
        statement.generateCodeExpression(aData, expression);
        expression.mergeExpression(source);
        // execution of statement block if the guard was successful
        source.append(MessageFormat.format("if ( {0}_alt_flag_{1} == TitanAlt_Status.ALT_YES) '{'\n", tempId, i));
        final StatementBlock block = ((Operation_Altguard) altGuard).getStatementBlock();
        if (inInterleave) {
            if (block != null && block.getSize() > 0) {
                if (block.hasReceivingStatement(0)) {
                    source.append(MessageFormat.format("continue {0}_branch{1};\n", tempId, i));
                } else {
                    source.append("{\n");
                    block.generateCode(aData, source);
                    source.append(MessageFormat.format("continue {0}_end;\n", tempId));
                    source.append("}\n");
                }
            } else {
                source.append(MessageFormat.format("continue {0}_end;\n", tempId));
            }
        } else {
            if (block != null && block.getSize() > 0) {
                source.append("{\n");
                block.generateCode(aData, source);
                if (block.hasReturn(CompilationTimeStamp.getBaseTimestamp()) != StatementBlock.ReturnStatus_type.RS_YES) {
                    source.append("break;\n");
                }
                source.append("}\n");
            }
        }
        source.append("}\n");
        source.append("}\n");
    }
    getLocation().update_location_object(aData, source);
    // error handling and taking the next snapshot in blocking mode
    source.append("if (");
    for (int i = 0; i < altGuards.size(); i++) {
        if (i > 0) {
            source.append(" && ");
        }
        source.append(MessageFormat.format("{0}_alt_flag_{1} == TitanAlt_Status.ALT_NO", tempId, i));
    }
    source.append(") {\n");
    source.append("throw new TtcnError(\"None of the branches can be chosen in the response and exception handling part of call statement in file");
    // TODO translate_string
    if (location != null && location.getFile() != null) {
        source.append(MessageFormat.format("in file {0} at line {1}", location.getFile().getName(), location.getLine()));
    }
    source.append("\");\n");
    source.append("}\n");
    source.append("TTCN_Snapshot.takeNew(true);\n");
    source.append("}\n");
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)

Example 8 with StatementBlock

use of org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock in project titan.EclipsePlug-ins by eclipse.

the class AltGuards method generateCodeAltstep.

/**
 * Generate code for an altstep
 *
 * @param aData the structure to put imports into and get temporal variable names from.
 * @param source the source code generated
 */
public void generateCodeAltstep(final JavaGenData aData, final StringBuilder source) {
    final boolean hasElse = hasElse();
    if (!hasElse) {
        source.append("TitanAlt_Status returnValue = TitanAlt_Status.ALT_NO;\n");
    }
    for (int i = 0; i < altGuards.size(); i++) {
        final AltGuard altGuard = altGuards.get(i);
        final altguard_type altGuardType = altGuard.getType();
        if (altGuardType.equals(altguard_type.AG_ELSE)) {
            source.append("TTCN_Snapshot.elseBranchReached();\n");
            final StatementBlock block = altGuard.getStatementBlock();
            if (block.getSize() > 0) {
                source.append("{\n");
                // TODO debugger
                block.generateCode(aData, source);
                source.append("}\n");
            }
            if (block.hasReturn(CompilationTimeStamp.getBaseTimestamp()) != ReturnStatus_type.RS_YES) {
                source.append("return TitanAlt_Status.ALT_YES;\n");
            }
            break;
        } else {
            final AtomicInteger blockCount = new AtomicInteger(0);
            final IValue guardExpression = altGuard.getGuardExpression();
            if (guardExpression != null) {
                guardExpression.getLocation().update_location_object(aData, source);
                guardExpression.generateCodeTmp(aData, source, "if (", blockCount);
                source.append(") {\n");
                blockCount.incrementAndGet();
            }
            boolean canRepeat = false;
            final ExpressionStruct expression = new ExpressionStruct();
            switch(altGuardType) {
                case AG_OP:
                    {
                        final Statement statement = ((Operation_Altguard) altGuard).getGuardStatement();
                        altGuard.getLocation().update_location_object(aData, source);
                        statement.generateCodeExpression(aData, expression);
                        canRepeat = statement.canRepeat();
                    }
                    break;
                case AG_REF:
                    {
                        // the guard operation is an altstep instance
                        final Reference reference = ((Referenced_Altguard) altGuard).getGuardReference();
                        altGuard.getLocation().update_location_object(aData, source);
                        final Assignment altstep = reference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
                        expression.expression.append(MessageFormat.format("{0}_instance(", altstep.getGenNameFromScope(aData, source, myScope, "")));
                        final ISubReference subreference = reference.getSubreferences().get(0);
                        ((ParameterisedSubReference) subreference).getActualParameters().generateCodeAlias(aData, expression);
                        source.append(')');
                        canRepeat = true;
                    }
                    break;
                case AG_INVOKE:
                    {
                        // the guard operation is an altstep invocation
                        altGuard.getLocation().update_location_object(aData, source);
                        ((Invoke_Altguard) altGuard).generateCodeInvokeInstance(aData, expression);
                        canRepeat = true;
                    }
                    break;
                default:
                    ErrorReporter.INTERNAL_ERROR("unknown altguard type encountered `" + getFullName() + "''");
                    return;
            }
            if (expression.preamble.length() > 0 || expression.postamble.length() > 0) {
                if (blockCount.get() == 0) {
                    source.append("{\n");
                    blockCount.set(blockCount.get() + 1);
                }
                final String tempId = aData.getTemporaryVariableName();
                source.append(MessageFormat.format("TitanAlt_Status {0};\n", tempId));
                source.append("{\n");
                source.append(expression.preamble);
                source.append(MessageFormat.format("{0}.assign({1});\n", tempId, expression.expression));
                source.append(expression.postamble);
                source.append("}\n");
                source.append(MessageFormat.format("switch ({0}) '{'\n", tempId));
            } else {
                source.append(MessageFormat.format("switch ({0}) '{'\n", expression.expression));
            }
            source.append("case ALT_YES:\n");
            final StatementBlock block = altGuard.getStatementBlock();
            if (block != null && block.getSize() > 0) {
                source.append("{\n");
                // TODO handle debugger
                block.generateCode(aData, source);
                source.append("}\n");
            }
            if (block == null || block.hasReturn(CompilationTimeStamp.getBaseTimestamp()) != ReturnStatus_type.RS_YES) {
                source.append("return TitanAlt_Status.ALT_YES;\n");
            }
            if (canRepeat) {
                source.append("case ALT_REPEAT:\n");
                source.append("return TitanAlt_Status.ALT_REPEAT;\n");
            }
            if (altGuardType == altguard_type.AG_REF || altGuardType == altguard_type.AG_INVOKE) {
                source.append("case ALT_BREAK:\n");
                source.append("return TitanAlt_Status.ALT_BREAK;\n");
            }
            if (!hasElse) {
                source.append("case ALT_MAYBE:\n");
                source.append("returnValue = TitanAlt_Status.ALT_MAYBE;\n");
            }
            source.append("default:\n");
            source.append("break;\n");
            source.append("}\n");
            // closing statement blocks
            for (int j = 0; j < blockCount.get(); j++) {
                source.append("}\n");
            }
        }
    }
    if (!hasElse) {
        source.append("return returnValue;\n");
    }
}
Also used : AltGuard.altguard_type(org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard.altguard_type) Reference(org.eclipse.titan.designer.AST.Reference) ISubReference(org.eclipse.titan.designer.AST.ISubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) Assignment(org.eclipse.titan.designer.AST.Assignment) ISubReference(org.eclipse.titan.designer.AST.ISubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) IValue(org.eclipse.titan.designer.AST.IValue) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)

Example 9 with StatementBlock

use of org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock in project titan.EclipsePlug-ins by eclipse.

the class For_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    if (definitions != null) {
        definitions.check(timestamp);
    }
    if (initialAssignment != null) {
        initialAssignment.check(timestamp);
    }
    if (finalExpression != null) {
        finalExpression.setLoweridToReference(timestamp);
        final IValue lastValue = finalExpression.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
        final Type_type temp = lastValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        switch(temp) {
            case TYPE_BOOL:
                if (!lastValue.isUnfoldable(timestamp)) {
                    if (((Boolean_Value) lastValue).getValue()) {
                        finalExpression.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), UNNECESSARYCONTROL);
                    } else {
                        finalExpression.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), NEVERREACH);
                    }
                }
                break;
            default:
                location.reportSemanticError(OPERANDERROR);
                finalExpression.setIsErroneous(true);
                break;
        }
        if (finalExpression.getMyGovernor() == null) {
            finalExpression.setMyGovernor(new Boolean_Type());
        }
    }
    if (stepAssignment != null) {
        stepAssignment.check(timestamp);
    }
    if (statementblock != null) {
        statementblock.setMyLaicStmt(null, this);
        statementblock.check(timestamp);
    // warning for "return" has been removed. Not valid problem
    }
    lastTimeChecked = timestamp;
}
Also used : Boolean_Value(org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value) IValue(org.eclipse.titan.designer.AST.IValue) Boolean_Type(org.eclipse.titan.designer.AST.TTCN3.types.Boolean_Type) Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

Example 10 with StatementBlock

use of org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock in project titan.EclipsePlug-ins by eclipse.

the class Export_Debug_AST_Action method exportDebugAST.

private void exportDebugAST(final ZipOutputStream out, final Module module) throws Exception {
    out.putNextEntry(new ZipEntry("DebugAST_for_" + module.getIdentifier().getName() + ".txt"));
    out.write("*************************".getBytes());
    out.write(lineend);
    out.write(("Printing DEBUG information for module `" + module.getName() + "':").getBytes());
    out.write(lineend);
    out.write("*************************".getBytes());
    out.write(lineend);
    module.accept(new ASTVisitor() {

        private int padding = 0;

        @Override
        public int visit(IVisitableNode node) {
            if (node instanceof Assignment) {
                Assignment assignment = (Assignment) node;
                printInfoln(out, padding, assignment.getAssignmentName(), assignment.getFullName(), assignment.getLastTimeChecked(), assignment.getLocation());
            } else if (node instanceof Identifier) {
                printInfoln(out, padding, "identifier", ((Identifier) node).getDisplayName(), null, ((Identifier) node).getLocation());
            } else if (node instanceof Statement) {
                Statement statement = (Statement) node;
                printInfoln(out, padding, "statement", statement.getFullName(), statement.getLastTimeChecked(), statement.getLocation());
            } else if (node instanceof Reference) {
                Reference ref = (Reference) node;
                printInfoln(out, padding, "reference", ref.getFullName(), ref.getLastTimeChecked(), ref.getLocation());
                Assignment old = ref.getAssOld();
                if (old != null) {
                    printInfoln(out, padding + 1, "This reference was last pointing to " + old.getFullName() + " analyzed at " + old.getLastTimeChecked());
                }
            } else if (node instanceof ComponentTypeBody) {
                ComponentTypeBody body = (ComponentTypeBody) node;
                Map<String, Definition> map = body.getDefinitionMap();
                printInfoln(out, padding + 1, " contains definitions:");
                if (map != null) {
                    for (Map.Entry<String, Definition> entry : map.entrySet()) {
                        printInfoln(out, padding + 2, entry.getKey() + " was last checked at " + entry.getValue().getLastTimeChecked());
                    }
                }
            }
            if (node instanceof StatementBlock || node instanceof Definition) {
                padding++;
            }
            return super.visit(node);
        }

        @Override
        public int leave(IVisitableNode node) {
            if (node instanceof StatementBlock || node instanceof Definition) {
                padding--;
            }
            return super.leave(node);
        }
    });
    out.write("*************************".getBytes());
    out.write(lineend);
    out.write(("Printing DEBUG information for module `" + module.getName() + "' finished").getBytes());
    out.write(lineend);
    out.write("*************************".getBytes());
    out.write(lineend);
    out.closeEntry();
}
Also used : ComponentTypeBody(org.eclipse.titan.designer.AST.TTCN3.types.ComponentTypeBody) Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Statement) Reference(org.eclipse.titan.designer.AST.Reference) ZipEntry(java.util.zip.ZipEntry) Definition(org.eclipse.titan.designer.AST.TTCN3.definitions.Definition) ASTVisitor(org.eclipse.titan.designer.AST.ASTVisitor) IVisitableNode(org.eclipse.titan.designer.AST.IVisitableNode) Assignment(org.eclipse.titan.designer.AST.Assignment) ZipEntry(java.util.zip.ZipEntry) Identifier(org.eclipse.titan.designer.AST.Identifier) Map(java.util.Map) StatementBlock(org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock)

Aggregations

StatementBlock (org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock)21 IValue (org.eclipse.titan.designer.AST.IValue)11 Assignment (org.eclipse.titan.designer.AST.Assignment)8 Reference (org.eclipse.titan.designer.AST.Reference)8 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)7 Boolean_Type (org.eclipse.titan.designer.AST.TTCN3.types.Boolean_Type)7 IVisitableNode (org.eclipse.titan.designer.AST.IVisitableNode)6 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)6 Identifier (org.eclipse.titan.designer.AST.Identifier)5 Alt_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement)5 Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Statement)5 Assignment_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement)4 If_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement)4 ISubReference (org.eclipse.titan.designer.AST.ISubReference)3 Location (org.eclipse.titan.designer.AST.Location)3 Module (org.eclipse.titan.designer.AST.Module)3 Def_Altstep (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep)3 Def_Function (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)3 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)3 Map (java.util.Map)2