Package org.rascalmpl.interpreter.staticErrors

Examples of org.rascalmpl.interpreter.staticErrors.RedeclaredVariable


        TypedMultiVariablePattern tmvVar = (TypedMultiVariablePattern) child;
        Type childType = child.getType(env, null);
        String name = tmvVar.getName();
       
        if (!tmvVar.isAnonymous() && allVars.containsKey(name)) {
          throw new RedeclaredVariable(name, getAST());
        }
       
        if(childType.comparable(staticSubjectElementType)
            || (tmvVar.bindingInstance() && childType.comparable(staticSetSubjectType))) {
          tmvVar.covertToSetType();
          if (!tmvVar.isAnonymous()) {
            patVars.add(name);
            allVars.put(name,  (IVarPattern)child);
          }
          varName[nVar] = name;
          varPat[nVar] = child;
          isSetVar[nVar] = true;
          isBinding[nVar] = true;
          isNested[nVar] = false;
          ++nVar;
        } else {
          hasNext = false;
          return;
        }
      } else if(child instanceof TypedVariablePattern){
        TypedVariablePattern patVar = (TypedVariablePattern) child;
        Type childType = child.getType(env, null);
        String name = ((TypedVariablePattern)child).getName();
        if(!patVar.isAnonymous() && allVars.containsKey(name)){
          throw new RedeclaredVariable(name, getAST());
        }
        if(childType.comparable(staticSubjectElementType)){
          /*
           * An explicitly declared set or element variable.
           */
 
View Full Code Here


     
      // Initialize all pattern variables to ""
      for(String name : patternVars){
        if(!this.iWroteItMySelf
            && !ctx.getCurrentEnvt().declareVariable(tf.stringType(), name))
          throw new RedeclaredVariable(name, ctx.getCurrentAST());
        ctx.getCurrentEnvt().storeVariable(name, makeResult(tf.stringType(), empty, ctx));
      }
      this.iWroteItMySelf = true;
    }
   
View Full Code Here

        isListVar[i] = true;
        listVarOccurrences[i] = 1;
        ++nListVar;

        if(!tmvVar.isAnonymous() && allVars.contains(name)) {
          throw new RedeclaredVariable(name, getAST());
        } else if(tmvType.comparable(listSubject.getType().getElementType())
            || (tmvVar.bindingInstance() && tmvType.comparable(listSubject.getType()))) {
          tmvVar.convertToListType();
          if (!tmvVar.isAnonymous()) {
            allVars.add(name);
View Full Code Here

    Result<IValue> varRes = ctx.getCurrentEnvt().getSimpleVariable(name);
    if (varRes == null) {
      // inferred declaration
      declaredType = subject.getType();
      if (!ctx.getCurrentEnvt().declareVariable(declaredType, getName())) {
        throw new RedeclaredVariable(getName(), ctx.getCurrentAST());
      }
      ctx.getCurrentEnvt().storeVariable(name, subject);
      iWroteItMySelf = true;
      return true;
    }
    else if (varRes.getValue() == null) {
      declaredType = varRes.getType();
      if (!ctx.getCurrentEnvt().declareVariable(declaredType, getName())) {
        throw new RedeclaredVariable(getName(), ctx.getCurrentAST());
      }
      ctx.getCurrentEnvt().storeVariable(name, subject);
      iWroteItMySelf = true;
      return true;
    }
View Full Code Here

          Type declaredType = typeOf(__eval.getCurrentEnvt(), true, __eval);

          if (!__eval.getCurrentEnvt().declareVariable(declaredType,
              var.getName())) {
            throw new RedeclaredVariable(varAsString, var);
          }

          if (v.getType().isSubtypeOf(declaredType)) {
            // TODO: do we actually want to instantiate the locally
            // bound type parameters?
            Map<Type, Type> bindings = new HashMap<Type, Type>();
            declaredType.match(v.getType(), bindings);
            declaredType = declaredType.instantiate(bindings);
            // Was: r = makeResult(declaredType,
            // applyRules(v.getValue()));
            r = org.rascalmpl.interpreter.result.ResultFactory
                .makeResult(declaredType, v.getValue(), __eval);
            __eval.getCurrentEnvt().storeVariable(var.getName(), r);
          } else {
            throw new UnexpectedType(declaredType,
                v.getType(), var);
          }
        } else {
          Type declaredType = typeOf(__eval.getCurrentEnvt(), true, __eval);

          if (!__eval.getCurrentEnvt().declareVariable(declaredType,
              var.getName())) {
            throw new RedeclaredVariable(varAsString, var);
          }
        }
      }

      return r;
View Full Code Here

        // >

        if (m.end(2) > -1) { /* case (1): <X:regexp> */

          if (patternVars.contains(varName)) {
            throw new RedeclaredVariable(varName, this);
          }
          patternVars.add(varName);
          resultRegExp.add(new StaticInterpolationElement("("));
          interpolate(m.group(2), resultRegExp, patternVars);
          resultRegExp.add(new StaticInterpolationElement(")"));
View Full Code Here

          + "(type=" + subject.getType() + ") with " + declaredType
          + " " + name);
    }
 
    if (!anonymous && !iDeclaredItMyself && !ctx.getCurrentEnvt().declareVariable(declaredType, name)) {
      throw new RedeclaredVariable(name, ctx.getCurrentAST());
    }
   
    iDeclaredItMyself = true;
   
    if (subject.getType().isSubtypeOf(Factory.Args)) {
View Full Code Here

    Result<IValue> varRes = ctx.getCurrentEnvt().getSimpleVariable(name);
    if (varRes == null) {
      // inferred declaration
      declaredType = subject.getType();
      if (!ctx.getCurrentEnvt().declareVariable(declaredType, getName())) {
        throw new RedeclaredVariable(getName(), ctx.getCurrentAST());
      }
      ctx.getCurrentEnvt().storeVariable(((org.rascalmpl.semantics.dynamic.QualifiedName.Default) name).lastName(), subject);
      iWroteItMySelf = true;
      return true;
    }
    else if (varRes.getValue() == null) {
      declaredType = varRes.getType();
      if (!ctx.getCurrentEnvt().declareVariable(declaredType, getName())) {
        throw new RedeclaredVariable(getName(), ctx.getCurrentAST());
      }
      ctx.getCurrentEnvt().storeVariable(((org.rascalmpl.semantics.dynamic.QualifiedName.Default) name).lastName(), subject);
      iWroteItMySelf = true;
      return true;
    }
View Full Code Here

        if (var.isInitialized()) {
          Result<IValue> v = var.getInitial().interpret(eval);

          if (!eval.getCurrentEnvt().declareVariable(declaredType, var.getName())) {
            throw new RedeclaredVariable(Names.name(var.getName()), var);
          }

          if (v.getType().isSubtypeOf(declaredType)) {
            // TODO: do we actually want to instantiate the locally
            // bound type parameters?
View Full Code Here

TOP

Related Classes of org.rascalmpl.interpreter.staticErrors.RedeclaredVariable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.