Search in sources :

Example 76 with ExpressionStruct

use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.

the class Kill_Statement method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    aData.addCommonLibraryImport("TTCN_Runtime");
    final ExpressionStruct expression = new ExpressionStruct();
    if (componentReference == null) {
        aData.addBuiltinTypeImport("TitanComponent");
        expression.expression.append("TTCN_Runtime.kill_component(TitanComponent.ALL_COMPREF)");
    } else {
        final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
        final IValue last = componentReference.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
        referenceChain.release();
        if (last.getValuetype() == Value_type.REFERENCED_VALUE) {
            // the argument is a simple component reference
            last.generateCodeExpressionMandatory(aData, expression, true);
            expression.expression.append(".kill()");
        } else {
            boolean refers_to_self = false;
            if (last.getValuetype() == Value_type.EXPRESSION_VALUE) {
                // the argument is a special component reference (mtc, self, etc.)
                switch(((Expression_Value) last).getOperationType()) {
                    case MTC_COMPONENT_OPERATION:
                        {
                            Definition myDefinition = myStatementBlock.getMyDefinition();
                            if (myDefinition != null && myDefinition.getAssignmentType() == Assignment_type.A_TESTCASE) {
                                refers_to_self = true;
                            }
                            break;
                        }
                    case SELF_COMPONENT_OPERATION:
                        refers_to_self = true;
                    default:
                        break;
                }
            }
            if (refers_to_self) {
                expression.expression.append("TTCN_Runtime.kill_execution()");
            } else {
                expression.expression.append("TTCN_Runtime.kill_component(");
                last.generateCodeExpression(aData, expression, false);
                expression.expression.append(')');
            }
        }
    }
    expression.mergeExpression(source);
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Definition(org.eclipse.titan.designer.AST.TTCN3.definitions.Definition) Expression_Value(org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value) ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)

Example 77 with ExpressionStruct

use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.

the class Start_Timer_Statement method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final ExpressionStruct expression = new ExpressionStruct();
    timerReference.generateCode(aData, expression);
    expression.expression.append(".start(");
    if (timerValue != null) {
        timerValue.generateCodeExpression(aData, expression, true);
    }
    expression.expression.append(")");
    expression.mergeExpression(source);
}
Also used : ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)

Example 78 with ExpressionStruct

use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.

the class Map_Statement method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    // FIXME this is actually more complex
    final ExpressionStruct expression = new ExpressionStruct();
    // FIXME generate code for translation
    expression.expression.append("TTCN_Runtime.map_port(");
    componentReference1.generateCodeExpression(aData, expression, true);
    expression.expression.append(", ");
    // FIXME actually _portref and based on component type
    portReference1.generateCode(aData, expression);
    expression.expression.append(".get_name(), ");
    componentReference2.generateCodeExpression(aData, expression, true);
    expression.expression.append(", ");
    // FIXME actually _portref and based on component type
    portReference2.generateCode(aData, expression);
    expression.expression.append(".get_name()");
    expression.expression.append(")");
    expression.mergeExpression(source);
}
Also used : ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)

Example 79 with ExpressionStruct

use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.

the class Stop_Timer_Statement method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    if (timerReference == null) {
        source.append("TitanTimer.allStop();\n");
    } else {
        final ExpressionStruct expression = new ExpressionStruct();
        timerReference.generateCode(aData, expression);
        expression.expression.append(".stop()");
        expression.mergeExpression(source);
    }
}
Also used : ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)

Example 80 with ExpressionStruct

use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.

the class Testcase_Instance_Statement method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    source.append("\t\t");
    final ExpressionStruct expression = new ExpressionStruct();
    final Assignment testcase = testcaseReference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
    expression.expression.append(MessageFormat.format("{0}(", testcase.getGenNameFromScope(aData, source, myScope, "testcase_")));
    final List<ISubReference> subReferences = testcaseReference.getSubreferences();
    if (!subReferences.isEmpty() && subReferences.get(0) instanceof ParameterisedSubReference) {
        final ActualParameterList actualParList = ((ParameterisedSubReference) subReferences.get(0)).getActualParameters();
        if (actualParList.getNofParameters() > 0) {
            actualParList.generateCodeAlias(aData, expression);
            expression.expression.append(", ");
        }
    }
    if (timerValue != null) {
        expression.expression.append("true, ");
        timerValue.generateCodeExpression(aData, expression, true);
        expression.expression.append(')');
    } else {
        aData.addBuiltinTypeImport("TitanFloat");
        aData.addBuiltinTypeImport("Ttcn3Float");
        expression.expression.append("false, new TitanFloat( new Ttcn3Float( 0.0 ) ))");
    }
    expression.mergeExpression(source);
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) ISubReference(org.eclipse.titan.designer.AST.ISubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)

Aggregations

ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)79 IValue (org.eclipse.titan.designer.AST.IValue)38 IType (org.eclipse.titan.designer.AST.IType)22 Assignment (org.eclipse.titan.designer.AST.Assignment)21 ISubReference (org.eclipse.titan.designer.AST.ISubReference)19 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)17 Reference (org.eclipse.titan.designer.AST.Reference)15 Identifier (org.eclipse.titan.designer.AST.Identifier)10 TTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template)9 ArrayList (java.util.ArrayList)8 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)8 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)8 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)7 Array_Type (org.eclipse.titan.designer.AST.TTCN3.types.Array_Type)7 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)7 Type (org.eclipse.titan.designer.AST.Type)7 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)6 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)6 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)6 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)4