Search in sources :

Example 76 with Assignment

use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.

the class Embedded_PDV_Type method getTypeRefd.

@Override
public /**
 * {@inheritDoc}
 */
IType getTypeRefd(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
    if (null == myScope) {
        setIsErroneous(true);
        return this;
    }
    final Identifier identifier = new Identifier(Identifier_type.ID_ASN, EMBEDDED_PDV);
    final Assignments assignments = myScope.getAssignmentsScope();
    if (!assignments.hasAssignmentWithId(timestamp, identifier)) {
        setIsErroneous(true);
        return this;
    }
    final Assignment assignment = assignments.getLocalAssignmentByID(timestamp, identifier);
    if (null == assignment || null == assignment.getType(timestamp)) {
        setIsErroneous(true);
        return this;
    }
    return assignment.getType(timestamp);
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) Identifier(org.eclipse.titan.designer.AST.Identifier) Assignments(org.eclipse.titan.designer.AST.Assignments)

Example 77 with Assignment

use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.

the class External_Type method getTypeRefd.

@Override
public /**
 * {@inheritDoc}
 */
IType getTypeRefd(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
    if (null == myScope) {
        setIsErroneous(true);
        return this;
    }
    final Identifier identifier = new Identifier(Identifier_type.ID_ASN, "EXTERNAL");
    final Assignments assignments = myScope.getAssignmentsScope();
    if (!assignments.hasAssignmentWithId(timestamp, identifier)) {
        setIsErroneous(true);
        return this;
    }
    final Assignment assignment = assignments.getLocalAssignmentByID(timestamp, identifier);
    if (null == assignment || null == assignment.getType(timestamp)) {
        setIsErroneous(true);
        return this;
    }
    return assignment.getType(timestamp);
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) Identifier(org.eclipse.titan.designer.AST.Identifier) Assignments(org.eclipse.titan.designer.AST.Assignments)

Example 78 with Assignment

use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.

the class Referenced_Value method getExpressionGovernor.

@Override
public /**
 * {@inheritDoc}
 */
IType getExpressionGovernor(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
    if (myGovernor != null) {
        return myGovernor;
    }
    reference.setIsErroneous(false);
    final Assignment ass = reference.getRefdAssignment(timestamp, true);
    if (ass == null) {
        setIsErroneous(true);
        return null;
    }
    IType temporalType = null;
    switch(ass.getAssignmentType()) {
        case A_CONST:
        case A_EXT_CONST:
        case A_MODULEPAR:
        case A_MODULEPAR_TEMPLATE:
        case A_TEMPLATE:
        case A_TIMER:
        case A_VAR:
        case A_VAR_TEMPLATE:
        case A_FUNCTION_RVAL:
        case A_FUNCTION_RTEMP:
        case A_EXT_FUNCTION_RVAL:
        case A_EXT_FUNCTION_RTEMP:
        case A_PAR_VAL:
        case A_PAR_VAL_IN:
        case A_PAR_VAL_OUT:
        case A_PAR_VAL_INOUT:
        case A_PAR_TEMP_IN:
        case A_PAR_TEMP_OUT:
        case A_PAR_TEMP_INOUT:
            temporalType = ass.getType(timestamp);
            break;
        case A_FUNCTION:
        case A_EXT_FUNCTION:
            if (Expected_Value_type.EXPECTED_TEMPLATE.equals(expectedValue)) {
                getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDCALL1, ass.getDescription()));
            } else {
                getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDCALL2, ass.getDescription()));
            }
            setIsErroneous(true);
            return null;
        default:
            if (Expected_Value_type.EXPECTED_TEMPLATE.equals(expectedValue)) {
                getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDASSIGNMENT1, ass.getDescription()));
            } else {
                getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDASSIGNMENT2, ass.getDescription()));
            }
            setIsErroneous(true);
            return null;
    }
    if (temporalType == null) {
        setIsErroneous(true);
        return null;
    }
    temporalType = temporalType.getFieldType(timestamp, reference, 1, expectedValue, false);
    if (temporalType == null || reference.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return null;
    }
    return temporalType;
}
Also used : Value_Assignment(org.eclipse.titan.designer.AST.ASN1.Value_Assignment) Assignment(org.eclipse.titan.designer.AST.Assignment) IType(org.eclipse.titan.designer.AST.IType)

Example 79 with Assignment

use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.

the class Referenced_Value method isUnfoldable.

@Override
public /**
 * {@inheritDoc}
 */
boolean isUnfoldable(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    final Assignment ass = reference.getRefdAssignment(timestamp, false);
    if (ass == null) {
        return true;
    }
    switch(ass.getAssignmentType()) {
        case A_OBJECT:
        case A_OS:
        case A_CONST:
        case A_EXT_CONST:
        case A_MODULEPAR:
        case A_VAR:
        case A_FUNCTION_RVAL:
        case A_EXT_FUNCTION_RVAL:
        case A_PAR_VAL:
        case A_PAR_VAL_IN:
        case A_PAR_VAL_OUT:
        case A_PAR_VAL_INOUT:
            break;
        default:
            return true;
    }
    final IValue last = getValueRefdLast(timestamp, expectedValue, referenceChain);
    if (last == this || last == null) {
        return true;
    }
    return last.isUnfoldable(timestamp, expectedValue, referenceChain);
}
Also used : Value_Assignment(org.eclipse.titan.designer.AST.ASN1.Value_Assignment) Assignment(org.eclipse.titan.designer.AST.Assignment) IValue(org.eclipse.titan.designer.AST.IValue)

Example 80 with Assignment

use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.

the class ComponentCreateExpression method generateCodeExpressionExpression.

@Override
public /**
 * {@inheritDoc}
 */
void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
    aData.addCommonLibraryImport("TTCN_Runtime");
    expression.expression.append("TTCN_Runtime.create_component(");
    // the type of the component (module name and identifier)
    final Assignment assignment = componentReference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
    if (assignment == null || !Assignment_type.A_TYPE.equals(assignment.getAssignmentType())) {
        ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for expression `" + getFullName() + "''");
        return;
    }
    IType componentType = assignment.getType(CompilationTimeStamp.getBaseTimestamp()).getFieldType(CompilationTimeStamp.getBaseTimestamp(), componentReference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
    if (componentType == null) {
        ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for expression `" + getFullName() + "''");
        return;
    }
    componentType = componentType.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
    if (!Type_type.TYPE_COMPONENT.equals(componentType.getTypetype())) {
        ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for expression `" + getFullName() + "''");
        return;
    }
    ((Component_Type) componentType).getComponentBody().generateCodeComponentTypeName(expression);
    expression.expression.append(", ");
    // third argument: component name
    if (name != null) {
        final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
        final IValue last = name.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
        referenceChain.release();
        if (Value_type.CHARSTRING_VALUE.equals(last.getValuetype())) {
            // TODO check why translate
            expression.expression.append(MessageFormat.format("\"{0}\"", ((Charstring_Value) last).getValue()));
        } else {
            name.generateCodeExpressionMandatory(aData, expression, false);
        }
    } else {
        expression.expression.append("null");
    }
    expression.expression.append(", ");
    // fourth argument location
    if (location != null) {
        final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
        final IValue last = location.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
        referenceChain.release();
        if (Value_type.CHARSTRING_VALUE.equals(last.getValuetype())) {
            // TODO check why translate
            expression.expression.append(MessageFormat.format("\"{0}\"", ((Charstring_Value) last).getValue()));
        } else {
            location.generateCodeExpressionMandatory(aData, expression, false);
        }
    } else {
        expression.expression.append("null");
    }
    // fifth argument: alive flag
    expression.expression.append(MessageFormat.format(", {0})", isAlive ? "true" : "false"));
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) IValue(org.eclipse.titan.designer.AST.IValue) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

Assignment (org.eclipse.titan.designer.AST.Assignment)141 Reference (org.eclipse.titan.designer.AST.Reference)48 IType (org.eclipse.titan.designer.AST.IType)41 ISubReference (org.eclipse.titan.designer.AST.ISubReference)39 IValue (org.eclipse.titan.designer.AST.IValue)31 Identifier (org.eclipse.titan.designer.AST.Identifier)25 ArrayList (java.util.ArrayList)24 Module (org.eclipse.titan.designer.AST.Module)22 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)16 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)14 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)14 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)14 Assignments (org.eclipse.titan.designer.AST.Assignments)13 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)13 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)10 Location (org.eclipse.titan.designer.AST.Location)9 ArrayDimensions (org.eclipse.titan.designer.AST.TTCN3.values.ArrayDimensions)8 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)7 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)7 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)6