Search in sources :

Example 11 with Identifier

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

the class Enumerated_Value method getDeclaration.

@Override
public /**
 * {@inheritDoc}
 */
Declaration getDeclaration() {
    IType type = getMyGovernor();
    if (type == null) {
        return null;
    }
    type = type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
    if (type instanceof ITypeWithComponents) {
        final Identifier resultId = ((ITypeWithComponents) type).getComponentIdentifierByName(value);
        return Declaration.createInstance(type.getDefiningAssignment(), resultId);
    }
    return null;
}
Also used : Identifier(org.eclipse.titan.designer.AST.Identifier) ITypeWithComponents(org.eclipse.titan.designer.AST.ITypeWithComponents) IType(org.eclipse.titan.designer.AST.IType)

Example 12 with Identifier

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

the class Set_Value method evaluateIspresent.

@Override
public /**
 * {@inheritDoc}
 */
boolean evaluateIspresent(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
        return true;
    }
    final IType type = myGovernor.getTypeRefdLast(timestamp);
    if (type.getIsErroneous(timestamp)) {
        return false;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            return false;
        case fieldSubReference:
            final Identifier fieldId = ((FieldSubReference) subreference).getId();
            switch(type.getTypetype()) {
                case TYPE_TTCN3_SET:
                    if (!((TTCN3_Set_Type) type).hasComponentWithName(fieldId.getName())) {
                        return false;
                    }
                    break;
                case TYPE_ASN1_SET:
                    if (!((ASN1_Set_Type) type).hasComponentWithName(fieldId)) {
                        return false;
                    }
                    break;
                default:
                    return false;
            }
            if (values.hasNamedValueWithName(fieldId)) {
                // we can move on with the check
                return values.getNamedValueByName(fieldId).getValue().evaluateIspresent(timestamp, reference, actualSubReference + 1);
            }
            if (Type_type.TYPE_TTCN3_SET.equals(type.getTypetype())) {
                return false;
            }
            final CompField compField = ((ASN1_Set_Type) type).getComponentByName(fieldId);
            if (compField.isOptional()) {
                // create an explicit omit value
                final Value result = new Omit_Value();
                final BridgingNamedNode bridge = new BridgingNamedNode(this, "." + fieldId.getDisplayName());
                result.setFullNameParent(bridge);
                result.setMyScope(getMyScope());
                return result.evaluateIspresent(timestamp, reference, actualSubReference + 1);
            } else if (compField.hasDefault()) {
                return compField.getDefault().evaluateIspresent(timestamp, reference, actualSubReference + 1);
            }
            return false;
        case parameterisedSubReference:
            return false;
        default:
            return false;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) Identifier(org.eclipse.titan.designer.AST.Identifier) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) ASN1_Set_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type) BridgingNamedNode(org.eclipse.titan.designer.AST.BridgingNamedNode) IType(org.eclipse.titan.designer.AST.IType)

Example 13 with Identifier

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

the class Set_Value method evaluateIsbound.

@Override
public /**
 * {@inheritDoc}
 */
boolean evaluateIsbound(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
        return true;
    }
    final IType type = myGovernor.getTypeRefdLast(timestamp);
    if (type.getIsErroneous(timestamp)) {
        return false;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            return false;
        case fieldSubReference:
            final Identifier fieldId = ((FieldSubReference) subreference).getId();
            switch(type.getTypetype()) {
                case TYPE_TTCN3_SET:
                    if (!((TTCN3_Set_Type) type).hasComponentWithName(fieldId.getName())) {
                        return false;
                    }
                    break;
                case TYPE_ASN1_SET:
                    if (!((ASN1_Set_Type) type).hasComponentWithName(fieldId)) {
                        return false;
                    }
                    break;
                default:
                    return false;
            }
            if (values.hasNamedValueWithName(fieldId)) {
                // we can move on with the check
                return values.getNamedValueByName(fieldId).getValue().evaluateIsbound(timestamp, reference, actualSubReference + 1);
            }
            if (Type_type.TYPE_TTCN3_SET.equals(type.getTypetype())) {
                return false;
            }
            final CompField compField = ((ASN1_Set_Type) type).getComponentByName(fieldId);
            if (compField.isOptional()) {
                // create an explicit omit value
                final Value result = new Omit_Value();
                final BridgingNamedNode bridge = new BridgingNamedNode(this, "." + fieldId.getDisplayName());
                result.setFullNameParent(bridge);
                result.setMyScope(getMyScope());
                return result.evaluateIsbound(timestamp, reference, actualSubReference + 1);
            } else if (compField.hasDefault()) {
                return compField.getDefault().evaluateIsbound(timestamp, reference, actualSubReference + 1);
            }
            return false;
        case parameterisedSubReference:
            return false;
        default:
            return false;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) Identifier(org.eclipse.titan.designer.AST.Identifier) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) ASN1_Set_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type) BridgingNamedNode(org.eclipse.titan.designer.AST.BridgingNamedNode) IType(org.eclipse.titan.designer.AST.IType)

Example 14 with Identifier

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

the class InternalMakefileGenerator method addTTCN3Module.

/**
 * Adds a file to the list of TTCN-3 files.
 * <p/>
 * The directory of the file must always point to a working directory,
 * or a central storage directory.
 *
 * @param file      the file to be added.
 * @param directory in which this file can be found (null if the working
 *                  directory of the actual project)
 */
public void addTTCN3Module(final IFile file, final String directory) {
    ProjectSourceParser parser = GlobalParser.getProjectSourceParser(file.getProject());
    String moduleName = parser.containedModuleName(file);
    if (moduleName == null) {
        if (file.isSynchronized(IResource.DEPTH_ZERO)) {
            ErrorReporter.logWarning("file " + file.getFullPath().toOSString() + " is out-of sync with the file system");
        } else {
            ErrorReporter.logWarning("file " + file.getFullPath().toOSString() + " even tough it has ttcn extension is added as on other file since the on-the-fly analyzer was not able to find a valid module inside");
        }
        addOtherFiles(file, directory);
        return;
    }
    final Identifier identifier = new Identifier(Identifier_type.ID_NAME, moduleName);
    ModuleStruct module;
    final IPath fileLocation = file.getLocation();
    if (fileLocation == null) {
        final String originalLocation = directory + File.separatorChar + file.getName();
        module = new ModuleStruct(directory, originalLocation, file.getName(), identifier.getTtcnName());
    } else {
        final String originalLocation = fileLocation.toOSString();
        module = new ModuleStruct(directory, originalLocation, fileLocation.lastSegment(), identifier.getTtcnName());
    }
    module.setRegular(fileLocation != null && "ttcn".equals(file.getFileExtension()) && file.getName().equals(moduleName + ".ttcn"));
    ttcn3Modules.add(module);
}
Also used : Identifier(org.eclipse.titan.designer.AST.Identifier) IPath(org.eclipse.core.runtime.IPath) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser)

Example 15 with Identifier

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

the class Definitions method getAssBySRef.

@Override
public /**
 * {@inheritDoc}
 */
Assignment getAssBySRef(final CompilationTimeStamp timestamp, final Reference reference, final IReferenceChain refChain) {
    if (reference.getModuleIdentifier() != null) {
        return getModuleScope().getAssBySRef(timestamp, reference);
    }
    final Identifier identifier = reference.getId();
    if (identifier == null) {
        return getModuleScope().getAssBySRef(timestamp, reference);
    }
    if (lastUniquenessCheckTimeStamp == null) {
        createDefinitionMap(timestamp);
    }
    // uniqueness shall be reported only after checking all the definitions
    final Definition result = definitionMap.get(identifier.getName());
    if (result != null) {
        return result;
    }
    return getParentScope().getAssBySRef(timestamp, reference);
}
Also used : Identifier(org.eclipse.titan.designer.AST.Identifier)

Aggregations

Identifier (org.eclipse.titan.designer.AST.Identifier)176 IType (org.eclipse.titan.designer.AST.IType)75 ISubReference (org.eclipse.titan.designer.AST.ISubReference)57 IValue (org.eclipse.titan.designer.AST.IValue)39 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)38 Type (org.eclipse.titan.designer.AST.Type)35 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)33 Assignment (org.eclipse.titan.designer.AST.Assignment)25 ArrayList (java.util.ArrayList)24 Location (org.eclipse.titan.designer.AST.Location)24 Reference (org.eclipse.titan.designer.AST.Reference)22 Module (org.eclipse.titan.designer.AST.Module)21 HashMap (java.util.HashMap)16 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)15 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)12 Value (org.eclipse.titan.designer.AST.Value)12 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)11 IASN1Type (org.eclipse.titan.designer.AST.ASN1.IASN1Type)10 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)10 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)10