Search in sources :

Example 21 with ExpressionStruct

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

the class Getreply_Statement method generateCodeExpression.

@Override
public /**
 * {@inheritDoc}
 */
void generateCodeExpression(final JavaGenData aData, final ExpressionStruct expression) {
    if (portReference != null) {
        portReference.generateCode(aData, expression);
        expression.expression.append(".getreply(");
        if (parameter != null) {
            // FIXME handle redirect
            parameter.generateCode(aData, expression, Restriction_type.TR_NONE);
            final IType signature = parameter.getTemplateBody().getMyGovernor();
            final IType signatureType = signature.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
            final IType returnType = ((Signature_Type) signatureType).getSignatureReturnType();
            if (returnType != null) {
                expression.expression.append(".set_value_template(");
                if (valueMatch != null) {
                    valueMatch.generateCode(aData, expression, Restriction_type.TR_NONE);
                } else {
                    // the value match is not present
                    // we must substitute it with ? in the signature template
                    expression.expression.append(MessageFormat.format("new {0}(template_sel.ANY_VALUE)", returnType.getGenNameTemplate(aData, expression.expression, myScope)));
                }
                expression.expression.append(')');
            }
            expression.expression.append(", ");
            generateCodeExprFromclause(aData, expression);
            // FIXME handle redirections
            expression.expression.append(", ");
            if (redirectSender == null) {
                expression.expression.append("null");
            } else {
                redirectSender.generateCode(aData, expression);
            }
        } else {
            // the signature template is not present
            generateCodeExprFromclause(aData, expression);
            expression.expression.append(", ");
            if (redirectSender == null) {
                expression.expression.append("null");
            } else {
                redirectSender.generateCode(aData, expression);
            }
        }
        // FIXME handle index redirection
        expression.expression.append(", null");
    } else {
        // the operation refers to any port
        expression.expression.append("TitanPort.any_getreply(");
        generateCodeExprFromclause(aData, expression);
        expression.expression.append(", ");
        if (redirectSender == null) {
            expression.expression.append("null");
        } else {
            redirectSender.generateCode(aData, expression);
        }
    }
    expression.expression.append(')');
}
Also used : Signature_Type(org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type) IType(org.eclipse.titan.designer.AST.IType)

Example 22 with ExpressionStruct

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

the class Invoke_Altguard method generateCodeInvokeInstance.

/**
 * Generate code for an alt guard
 *
 * @param aData the structure to put imports into and get temporal variable names from.
 * @param expression the expression to generate the source to
 */
public void generateCodeInvokeInstance(final JavaGenData aData, final ExpressionStruct expression) {
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final IValue last = value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
    referenceChain.release();
    if (last.getValuetype() == Value_type.ALTSTEP_REFERENCE_VALUE) {
        Def_Altstep altstep = ((Altstep_Reference_Value) last).getReferredAltstep();
        expression.expression.append(MessageFormat.format("{0}_instance(", altstep.getGenNameFromScope(aData, expression.expression, myScope, "")));
        actualParameterList.generateCodeAlias(aData, expression);
    } else {
        value.generateCodeExpressionMandatory(aData, expression, true);
        expression.expression.append(".invoke(");
        IType governor = value.getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
        governor = governor.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
        actualParameterList.generateCodeAlias(aData, expression);
    }
    expression.expression.append(')');
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Altstep_Reference_Value(org.eclipse.titan.designer.AST.TTCN3.values.Altstep_Reference_Value) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Def_Altstep(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep) IType(org.eclipse.titan.designer.AST.IType)

Example 23 with ExpressionStruct

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

the class Done_Statement method generateCodeExpression.

@Override
public /**
 * {@inheritDoc}
 */
void generateCodeExpression(final JavaGenData aData, final ExpressionStruct expression) {
    aData.addCommonLibraryImport("TTCN_Runtime");
    aData.addBuiltinTypeImport("TitanComponent");
    if (componentreference != null) {
        if (doneMatch != null) {
            // value returning done
            // figure out what type the done() function belongs to
            IType t = doneMatch.getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
            if (t == null) {
                ErrorReporter.INTERNAL_ERROR("Encountered a done with unknown governor `" + getFullName() + "''");
                return;
            }
            while (t instanceof Referenced_Type && !t.hasDoneAttribute()) {
                final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
                t = ((IReferencingType) t).getTypeRefd(CompilationTimeStamp.getBaseTimestamp(), refChain);
                refChain.release();
            }
            if (!t.hasDoneAttribute()) {
                ErrorReporter.INTERNAL_ERROR("Encountered a done return type without done attribute `" + getFullName() + "''");
                return;
            }
            // determine whether the done() function is in the same module
            final Module t_module = t.getMyScope().getModuleScope();
            if (t_module != myStatementBlock.getModuleScope()) {
                expression.expression.append(MessageFormat.format("{0}.", t_module.getIdentifier().getName()));
            }
            expression.expression.append("done(");
            componentreference.generateCodeExpression(aData, expression, true);
            expression.expression.append(", ");
            // FIXME handle decoded match
            doneMatch.generateCode(aData, expression, Restriction_type.TR_NONE);
        // expression.expression.append(", ");
        // FIXME handle value redirection
        } else {
            // simple done
            componentreference.generateCodeExpressionMandatory(aData, expression, true);
            expression.expression.append(".done(");
        }
        // FIXME handle index redirection
        expression.expression.append(')');
    } else if (isAny) {
        // any component.done
        expression.expression.append("TTCN_Runtime.component_done(TitanComponent.ANY_COMPREF)");
    } else {
        // all component.done
        expression.expression.append("TTCN_Runtime.component_done(TitanComponent.ALL_COMPREF)");
    }
}
Also used : IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Module(org.eclipse.titan.designer.AST.Module) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) IType(org.eclipse.titan.designer.AST.IType)

Example 24 with ExpressionStruct

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

the class Function_Applied_Statement method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    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.ALTSTEP_REFERENCE_VALUE)) {
    // TODO Optimize for easily resolvable value
    }
    dereferredValue.generateCodeExpressionMandatory(aData, expression, true);
    expression.expression.append(".invoke(");
    if (actualParameterList2 != null && actualParameterList2.getNofParameters() > 0) {
        actualParameterList2.generateCodeAlias(aData, expression);
    }
    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 25 with ExpressionStruct

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

the class Getcall_Statement method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final ExpressionStruct expression = new ExpressionStruct();
    generateCodeExpression(aData, expression);
    PortGenerator.generateCodeStandalone(aData, source, expression.expression.toString(), getLocation());
}
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