Esempio n. 1
0
 @Override
 public VariableDeclaration clone() {
   Expression expression = initialization();
   Expression clonedExpression = null;
   if (expression != null) {
     clonedExpression = expression.clone();
   }
   return new VariableDeclaration(signature().clone(), clonedExpression);
 }
Esempio n. 2
0
 public V variable() {
   Expression init = initialization();
   Expression initClone = (init == null ? null : init.clone());
   V result =
       (V) ((VariableDeclarator<?, V>) parent()).createVariable(signature().clone(), initClone);
   result.setUniParent(parent());
   result.setOrigin(this);
   transform(result);
   return result;
 }
Esempio n. 3
0
 @Override
 public VerificationResult verifySelf() {
   VerificationResult result =
       checkNull(signature(), "The variable declaration has no signature", Valid.create());
   Expression initialization = initialization();
   if (initialization != null) {
     Type initType = null;
     try {
       initType = initialization.getType();
     } catch (LookupException e) {
       result =
           result.and(
               new BasicProblem(
                   this, "Cannot calculate the type of the initialization expression"));
     }
     Type variableType = null;
     try {
       variableType = variable().getType();
     } catch (LookupException e) {
       result =
           result.and(
               new BasicProblem(this, "Cannot calculate the type of the declared variable."));
     }
     if (initType != null && variableType != null) {
       try {
         if (!initType.subTypeOf(variableType)) {
           result =
               result.and(
                   new BasicProblem(
                       this,
                       "The type of the initializer ("
                           + initType.getFullyQualifiedName()
                           + ") is not a subtype of the type of the declared variable ("
                           + variableType.getFullyQualifiedName()
                           + ")."));
           initialization.getType().subTypeOf(variable().getType());
         }
       } catch (LookupException e) {
         result =
             result.and(
                 new BasicProblem(
                     this,
                     "Cannot determine the relation between the type of the initializer and the type of the declared variable."));
       }
     }
   }
   return result;
 }
Esempio n. 4
0
 public void setInitialization(Expression expression) {
   if (expression != null) {
     _expression.connectTo(expression.parentLink());
   } else {
     _expression.connectTo(null);
   }
 }