Search in sources :

Example 66 with ExpressionStruct

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

the class Raise_Statement method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final ExpressionStruct expression = new ExpressionStruct();
    portReference.generateCode(aData, expression);
    expression.expression.append(".raise( new ");
    signatureReference.generateCode(aData, expression);
    expression.expression.append("_exception(");
    final TTCN3Template templateBody = parameter.getTemplateBody();
    if (parameter.getDerivedReference() == null && Template_type.SPECIFIC_VALUE.equals(templateBody.getTemplatetype())) {
        // the exception is a value: optimization is possible
        final IValue value = ((SpecificValue_Template) templateBody).getSpecificValue();
        // FIXME implement the case where cast is needed (if really needed)
        value.generateCodeExpressionMandatory(aData, expression, true);
    } else {
        parameter.generateCode(aData, expression, Restriction_type.TR_NONE);
    }
    expression.expression.append(')');
    if (toClause != null) {
        expression.expression.append(", ");
        toClause.generateCodeExpression(aData, expression, true);
    }
    expression.expression.append(" )");
    expression.mergeExpression(source);
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template) ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)

Example 67 with ExpressionStruct

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

the class Referenced_Testcase_Instance_Statement method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    aData.addBuiltinTypeImport("TitanFloat");
    aData.addBuiltinTypeImport("Ttcn3Float");
    final ExpressionStruct expression = new ExpressionStruct();
    final IValue last = dereferredValue.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
    if (last.getValuetype().equals(Value_type.TESTCASE_REFERENCE_VALUE)) {
    // TODO Optimize for easily resolvable value
    }
    dereferredValue.generateCodeExpressionMandatory(aData, expression, true);
    expression.expression.append(".execute(");
    actualParameterList2.generateCodeAlias(aData, expression);
    if (actualParameterList2.getNofParameters() > 0) {
        expression.expression.append(", ");
    }
    if (timerValue == null) {
        expression.expression.append("false, new TitanFloat( new Ttcn3Float( 0.0 ) ))");
    } else {
        expression.expression.append("true, ");
        timerValue.generateCodeExpression(aData, expression, true);
        expression.expression.append(')');
    }
    expression.mergeExpression(source);
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)

Example 68 with ExpressionStruct

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

the class All_From_Template method generateCodeInitAllFrom.

public void generateCodeInitAllFrom(final JavaGenData aData, final StringBuilder source, final String name) {
    final IValue value = ((SpecificValue_Template) allFrom).getValue();
    Reference reference;
    if (value.getValuetype() == Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE) {
        // value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), null);
        reference = ((Undefined_LowerIdentifier_Value) value).getAsReference();
    } else {
        reference = ((Referenced_Value) value).getReference();
    }
    final ExpressionStruct expression = new ExpressionStruct();
    reference.generateCode(aData, expression);
    final Assignment assignment = reference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
    switch(assignment.getAssignmentType()) {
        case A_CONST:
        case A_EXT_CONST:
        case A_MODULEPAR:
        case A_VAR:
        case A_PAR_VAL:
        case A_PAR_VAL_IN:
        case A_PAR_VAL_OUT:
        case A_PAR_VAL_INOUT:
        case A_FUNCTION_RVAL:
        case A_EXT_FUNCTION_RVAL:
            if (assignment.getType(CompilationTimeStamp.getBaseTimestamp()).fieldIsOptional(reference.getSubreferences())) {
                expression.expression.append(".get()");
            }
            break;
        default:
            break;
    }
    // The caller will have to provide the for cycle with this variable
    source.append(MessageFormat.format("{0}.assign({1}.getAt(i_i));\n", name, expression.expression));
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) IValue(org.eclipse.titan.designer.AST.IValue) 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 69 with ExpressionStruct

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

the class Unmap_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.unmap_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 70 with ExpressionStruct

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

the class Deactivate_Statement method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    aData.addCommonLibraryImport("TTCN_Default");
    if (deactivate == null) {
        source.append("TTCN_Default.deactivateAll();\n");
        return;
    }
    final ExpressionStruct expression = new ExpressionStruct();
    expression.expression.append("TTCN_Default.deactivate(");
    deactivate.generateCodeExpression(aData, expression, true);
    expression.expression.append(");\n");
    expression.mergeExpression(source);
}
Also used : ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)

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