コード例 #1
0
  @Override
  public void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged)
      throws ReParseException {
    if (isDamaged) {
      throw new ReParseException();
    }

    if (reference != null) {
      reference.updateSyntax(reparser, false);
      reparser.updateLocation(reference.getLocation());
    }
  }
コード例 #2
0
  @Override
  public IType getFieldType(
      final CompilationTimeStamp timestamp,
      final Reference reference,
      final int actualSubReference,
      final Expected_Value_type expectedIndex,
      final IReferenceChain refChain,
      final boolean interruptIfOptional) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (subreferences.size() <= actualSubReference) {
      return this;
    }

    final ISubReference subreference = subreferences.get(actualSubReference);
    switch (subreference.getReferenceType()) {
      case arraySubReference:
        if (subreferences.size() > actualSubReference + 1) {
          subreference
              .getLocation()
              .reportSemanticError(ArraySubReference.INVALIDSTRINGELEMENTINDEX);
          return null;
        } else if (subreferences.size() == actualSubReference + 1) {
          reference.setStringElementReferencing();
        }
        return this;
      case fieldSubReference:
        subreference
            .getLocation()
            .reportSemanticError(
                MessageFormat.format(
                    FieldSubReference.INVALIDSUBREFERENCE,
                    ((FieldSubReference) subreference).getId().getDisplayName(),
                    getTypename()));
        return null;
      case parameterisedSubReference:
        subreference
            .getLocation()
            .reportSemanticError(
                MessageFormat.format(
                    FieldSubReference.INVALIDSUBREFERENCE,
                    ((ParameterisedSubReference) subreference).getId().getDisplayName(),
                    getTypename()));
        return null;
      default:
        subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
        return null;
    }
  }
コード例 #3
0
 @Override
 public void setMyScope(final Scope scope) {
   super.setMyScope(scope);
   if (reference != null) {
     reference.setMyScope(scope);
   }
 }
コード例 #4
0
  public Function_Instance_Statement(final Reference reference) {
    this.reference = reference;

    if (reference != null) {
      reference.setFullNameParent(this);
    }
  }
コード例 #5
0
 @Override
 protected boolean memberAccept(ASTVisitor v) {
   if (reference != null && !reference.accept(v)) {
     return false;
   }
   return true;
 }
コード例 #6
0
  @Override
  public void findReferences(
      final ReferenceFinder referenceFinder, final List<Hit> foundIdentifiers) {
    if (reference == null) {
      return;
    }

    reference.findReferences(referenceFinder, foundIdentifiers);
  }
コード例 #7
0
  public Undefined_FieldSpecification(
      final Identifier identifier,
      final Defined_Reference reference,
      final boolean isOptional,
      final Reference defaultSetting) {
    super(identifier, isOptional);
    governorReference = reference;
    defaultSetting1 = defaultSetting;
    mDefaultSetting = null;

    if (null != governorReference) {
      governorReference.setFullNameParent(this);
    }
    if (null != defaultSetting1) {
      defaultSetting1.setFullNameParent(this);
    }
  }
コード例 #8
0
  @Override
  public void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
      return;
    }

    lastTimeChecked = timestamp;

    Assignment assignment = reference.getRefdAssignment(timestamp, true);
    if (assignment == null) {
      return;
    }

    if (myStatementBlock != null) {
      myStatementBlock.checkRunsOnScope(timestamp, assignment, reference, "call");
    }

    switch (assignment.getAssignmentType()) {
      case A_FUNCTION_RVAL:
      case A_EXT_FUNCTION_RVAL:
        location.reportConfigurableSemanticProblem(
            Platform.getPreferencesService()
                .getString(
                    ProductConstants.PRODUCT_ID_DESIGNER,
                    PreferenceConstants.REPORTUNUSEDFUNCTIONRETURNVALUES,
                    GeneralConstants.WARNING,
                    null),
            MessageFormat.format(UNUSEDRETURN1, assignment.getFullName()));
        break;
      case A_FUNCTION_RTEMP:
      case A_EXT_FUNCTION_RTEMP:
        location.reportConfigurableSemanticProblem(
            Platform.getPreferencesService()
                .getString(
                    ProductConstants.PRODUCT_ID_DESIGNER,
                    PreferenceConstants.REPORTUNUSEDFUNCTIONRETURNVALUES,
                    GeneralConstants.WARNING,
                    null),
            MessageFormat.format(UNUSEDRETURN2, assignment.getFullName()));
        break;
      default:
        break;
    }
  }
コード例 #9
0
  @Override
  public IType getFieldType(
      final CompilationTimeStamp timestamp,
      final Reference reference,
      final int actualSubReference,
      final Expected_Value_type expectedIndex,
      final IReferenceChain refChain,
      final boolean interruptIfOptional) {
    List<ISubReference> subreferences = reference.getSubreferences();
    if (subreferences.size() <= actualSubReference) {
      return this;
    }

    Expected_Value_type internalExpectation =
        expectedIndex == Expected_Value_type.EXPECTED_TEMPLATE
            ? Expected_Value_type.EXPECTED_DYNAMIC_VALUE
            : expectedIndex;

    ISubReference subreference = subreferences.get(actualSubReference);
    switch (subreference.getReferenceType()) {
      case arraySubReference:
        Value indexValue = ((ArraySubReference) subreference).getValue();
        if (indexValue != null) {
          indexValue.setLoweridToReference(timestamp);
          Type_type tempType = indexValue.getExpressionReturntype(timestamp, expectedIndex);

          switch (tempType) {
            case TYPE_INTEGER:
              IValue last = indexValue.getValueRefdLast(timestamp, expectedIndex, refChain);
              if (Value_type.INTEGER_VALUE.equals(last.getValuetype())) {
                Integer_Value lastInteger = (Integer_Value) last;
                if (lastInteger.isNative()) {
                  long temp = lastInteger.getValue();
                  if (temp < 0) {
                    indexValue
                        .getLocation()
                        .reportSemanticError(MessageFormat.format(NONNEGATIVINDEXEXPECTED, last));
                    indexValue.setIsErroneous(true);
                  }
                } else {
                  indexValue
                      .getLocation()
                      .reportSemanticError(
                          MessageFormat.format(TOOBIGINDEX, indexValue, getTypename()));
                  indexValue.setIsErroneous(true);
                }
              }
              break;
            case TYPE_UNDEFINED:
              indexValue.setIsErroneous(true);
              break;
            default:
              indexValue.getLocation().reportSemanticError(INTEGERINDEXEXPECTED);
              indexValue.setIsErroneous(true);
              break;
          }
        }

        if (getOfType() != null) {
          return getOfType()
              .getFieldType(
                  timestamp,
                  reference,
                  actualSubReference + 1,
                  internalExpectation,
                  refChain,
                  interruptIfOptional);
        }

        return null;
      case fieldSubReference:
        subreference
            .getLocation()
            .reportSemanticError(
                MessageFormat.format(
                    FieldSubReference.INVALIDSUBREFERENCE,
                    ((FieldSubReference) subreference).getId().getDisplayName(),
                    getTypename()));
        return null;
      case parameterisedSubReference:
        subreference
            .getLocation()
            .reportSemanticError(
                MessageFormat.format(
                    FieldSubReference.INVALIDSUBREFERENCE,
                    ((ParameterisedSubReference) subreference).getId().getDisplayName(),
                    getTypename()));
        return null;
      default:
        subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
        return null;
    }
  }
コード例 #10
0
  private void classifyFieldSpecification(final CompilationTimeStamp timestamp) {
    final IReferenceChain temporalReferenceChain =
        ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);

    if (isOptional && (null != defaultSetting1 || null != mDefaultSetting)) {
      location.reportSemanticError("OPTIONAL and DEFAULT are mutually exclusive");
      isOptional = false;
    }

    if (temporalReferenceChain.add(this) && null != governorReference) {
      governorReference.setMyScope(myObjectClass.getMyScope());

      if (null != defaultSetting1) {
        defaultSetting1.setMyScope(myObjectClass.getMyScope());
      }

      if (identifier.isvalidAsnObjectSetFieldReference()
          && governorReference.refersToSettingType(
              timestamp, Setting_type.S_OC, temporalReferenceChain)) {
        ObjectSet defaultObjectset = null;
        if (null != mDefaultSetting) {
          defaultObjectset = ParserFactory.createObjectSetDefinition(mDefaultSetting);
        }
        fieldSpecification =
            new ObjectSet_FieldSpecification(
                identifier, new ObjectClass_refd(governorReference), isOptional, defaultObjectset);
      } else if (identifier.isvalidAsnObjectFieldReference()
          && governorReference.refersToSettingType(
              timestamp, Setting_type.S_OC, temporalReferenceChain)) {
        ASN1Object defaultObject = null;
        if (null != defaultSetting1) {
          defaultObject = new ReferencedObject(defaultSetting1);
        } else if (null != mDefaultSetting) {
          defaultObject = new Object_Definition(mDefaultSetting);
        }

        fieldSpecification =
            new Object_FieldSpecification(
                identifier, new ObjectClass_refd(governorReference), isOptional, defaultObject);
      } else if (identifier.isvalidAsnValueFieldReference()
          && (governorReference.refersToSettingType(
                  timestamp, Setting_type.S_T, temporalReferenceChain)
              || governorReference.refersToSettingType(
                  timestamp, Setting_type.S_VS, temporalReferenceChain))) {
        IValue defaultValue = null;

        if (null != defaultSetting1) {
          if (defaultSetting1 instanceof Defined_Reference
              && null == defaultSetting1.getModuleIdentifier()) {
            defaultValue =
                new Undefined_LowerIdentifier_Value(defaultSetting1.getId().newInstance());
          } else {
            defaultValue = new Referenced_Value(defaultSetting1);
          }
        } else if (null != mDefaultSetting) {
          defaultValue = ParserFactory.createUndefinedBlockValue(mDefaultSetting);
        }
        fieldSpecification =
            new FixedTypeValue_FieldSpecification(
                identifier,
                new Referenced_Type(governorReference),
                false,
                isOptional,
                null != defaultSetting1 && null != mDefaultSetting,
                defaultValue);
      }
    }

    if (null == fieldSpecification) {
      location.reportSemanticError(CANNOTRECOGNISE);
      fieldSpecification =
          new Erroneous_FieldSpecification(
              identifier, isOptional, null != defaultSetting1 || null != mDefaultSetting);
    } else {
      if (null != myObjectClass) {
        fieldSpecification.setMyObjectClass(myObjectClass);
      }
    }

    fieldSpecification.setFullNameParent(getNameParent());
    fieldSpecification.setLocation(location);

    temporalReferenceChain.release();
  }