Esempio n. 1
0
        public override void Resolve(ResolutionContext rc)
        {
            //Contract.Requires(rc != null);

            if (Dummies.Count != Rhss.Count)
            {
                rc.Error(this.tok, "number of left-hand sides does not match number of right-hand sides");
            }

            foreach (var e in Rhss)
            {
                e.Resolve(rc);
            }

            rc.PushVarContext();
            foreach (var v in Dummies)
            {
                Contract.Assert(v != null);
                v.Register(rc);
                v.Resolve(rc);
            }
            for (QKeyValue kv = this.Attributes; kv != null; kv = kv.Next)
            {
                kv.Resolve(rc);
            }
            Body.Resolve(rc);
            rc.PopVarContext();
        }
Esempio n. 2
0
        public override void Resolve(ResolutionContext rc)
        {
            //Contract.Requires(rc != null);
            if (rc.TriggerMode)
            {
                rc.Error(this, "quantifiers are not allowed in triggers");
            }

            int previousTypeBinderState = rc.TypeBinderState;

            try
            {
                foreach (TypeVariable /*!*/ v in TypeParameters)
                {
                    Contract.Assert(v != null);
                    rc.AddTypeBinder(v);
                }

                rc.PushVarContext();
                foreach (Variable /*!*/ v in Dummies)
                {
                    Contract.Assert(v != null);
                    v.Register(rc);
                    v.Resolve(rc);
                }

                for (QKeyValue kv = this.Attributes; kv != null; kv = kv.Next)
                {
                    kv.Resolve(rc);
                }

                this.ResolveTriggers(rc);
                Body.Resolve(rc);
                rc.PopVarContext();

                // establish a canonical order of the type parameters
                this.TypeParameters = Type.SortTypeParams(TypeParameters,
                                                          new List <Type>(Dummies.Select(Item => Item.TypedIdent.Type).ToArray()), null);
            }
            finally
            {
                rc.TypeBinderState = previousTypeBinderState;
            }
        }
Esempio n. 3
0
    public override void Resolve(ResolutionContext rc) {
      //Contract.Requires(rc != null);
      if (rc.TriggerMode) {
        rc.Error(this, "quantifiers are not allowed in triggers");
      }

      int previousTypeBinderState = rc.TypeBinderState;
      try {
        foreach (TypeVariable/*!*/ v in TypeParameters) {
          Contract.Assert(v != null);
          rc.AddTypeBinder(v);
        }

        rc.PushVarContext();
        foreach (Variable/*!*/ v in Dummies) {
          Contract.Assert(v != null);
          v.Register(rc);
          v.Resolve(rc);
        }
        for (QKeyValue kv = this.Attributes; kv != null; kv = kv.Next) {
          kv.Resolve(rc);
        }
        this.ResolveTriggers(rc);
        Body.Resolve(rc);
        rc.PopVarContext();

        // establish a canonical order of the type parameters
        this.TypeParameters = Type.SortTypeParams(TypeParameters, new List<Type>(Dummies.Select(Item => Item.TypedIdent.Type).ToArray()), null);

      } finally {
        rc.TypeBinderState = previousTypeBinderState;
      }
    }
Esempio n. 4
0
 public override void Resolve(ResolutionContext rc)
 {
     //Contract.Requires(rc != null);
       rc.PushVarContext();
       foreach (Variable/*!*/ v in Locals) {
     Contract.Assert(v != null);
     rc.AddVariable(v, false);
       }
       foreach (Cmd/*!*/ cmd in Cmds) {
     Contract.Assert(cmd != null);
     cmd.Resolve(rc);
       }
       rc.PopVarContext();
 }
Esempio n. 5
0
    public override void Resolve(ResolutionContext rc) {
      //Contract.Requires(rc != null);
      if (Proc != null) {
        // already resolved
        return;
      }
      DeclWithFormals dwf = rc.LookUpProcedure(cce.NonNull(this.Name));
      Proc = dwf as Procedure;
      if (dwf == null) {
        rc.Error(this, "implementation given for undeclared procedure: {0}", this.Name);
      } else if (Proc == null) {
        rc.Error(this, "implementations given for function, not procedure: {0}", this.Name);
      }

      int previousTypeBinderState = rc.TypeBinderState;
      try {
        RegisterTypeParameters(rc);

        rc.PushVarContext();
        RegisterFormals(InParams, rc);
        RegisterFormals(OutParams, rc);

        foreach (Variable/*!*/ v in LocVars) {
          Contract.Assert(v != null);
          v.Register(rc);
          v.Resolve(rc);
        }
        foreach (Variable/*!*/ v in LocVars) {
          Contract.Assert(v != null);
          v.ResolveWhere(rc);
        }

        rc.PushProcedureContext();
        foreach (Block b in Blocks) {
          b.Register(rc);
        }

        ResolveAttributes(rc);

        rc.StateMode = ResolutionContext.State.Two;
        foreach (Block b in Blocks) {
          b.Resolve(rc);
        }
        rc.StateMode = ResolutionContext.State.Single;

        rc.PopProcedureContext();
        rc.PopVarContext();

        Type.CheckBoundVariableOccurrences(TypeParameters,
                                           new List<Type>(InParams.Select(Item => Item.TypedIdent.Type).ToArray()),
                                           new List<Type>(OutParams.Select(Item => Item.TypedIdent.Type).ToArray()),
                                           this.tok, "implementation arguments",
                                           rc);
      } finally {
        rc.TypeBinderState = previousTypeBinderState;
      }
      SortTypeParams();
    }
Esempio n. 6
0
    public override void Resolve(ResolutionContext rc) {
      //Contract.Requires(rc != null);
      rc.PushVarContext();

      foreach (IdentifierExpr/*!*/ ide in Modifies) {
        Contract.Assert(ide != null);
        ide.Resolve(rc);
      }

      int previousTypeBinderState = rc.TypeBinderState;
      try {
        RegisterTypeParameters(rc);

        RegisterFormals(InParams, rc);
        ResolveFormals(InParams, rc);  // "where" clauses of in-parameters are resolved without the out-parameters in scope
        foreach (Requires/*!*/ e in Requires) {
          Contract.Assert(e != null);
          e.Resolve(rc);
        }
        RegisterFormals(OutParams, rc);
        ResolveFormals(OutParams, rc);  // "where" clauses of out-parameters are resolved with both in- and out-parametes in scope

        rc.StateMode = ResolutionContext.State.Two;
        foreach (Ensures/*!*/ e in Ensures) {
          Contract.Assert(e != null);
          e.Resolve(rc);
        }
        rc.StateMode = ResolutionContext.State.Single;
        ResolveAttributes(rc);

        Type.CheckBoundVariableOccurrences(TypeParameters,
                                           new List<Type>(InParams.Select(Item => Item.TypedIdent.Type).ToArray()),
                                           new List<Type>(OutParams.Select(Item => Item.TypedIdent.Type).ToArray()),        
                                           this.tok, "procedure arguments",
                                           rc);

      } finally {
        rc.TypeBinderState = previousTypeBinderState;
      }

      rc.PopVarContext();

      SortTypeParams();
    }
Esempio n. 7
0
 public override void Resolve(ResolutionContext rc) {
   //Contract.Requires(rc != null);
   int previousTypeBinderState = rc.TypeBinderState;
   try {
     RegisterTypeParameters(rc);
     rc.PushVarContext();
     RegisterFormals(InParams, rc);
     RegisterFormals(OutParams, rc);
     ResolveAttributes(rc);
     if (Body != null)
     {
         rc.StateMode = ResolutionContext.State.StateLess;
         Body.Resolve(rc);
         rc.StateMode = ResolutionContext.State.Single;
     }
     rc.PopVarContext();
     Type.CheckBoundVariableOccurrences(TypeParameters,
                                        new List<Type>(InParams.Select(Item => Item.TypedIdent.Type).ToArray()),
                                        new List<Type>(OutParams.Select(Item => Item.TypedIdent.Type).ToArray()),
                                        this.tok, "function arguments",
                                        rc);
   } finally {
     rc.TypeBinderState = previousTypeBinderState;
   }
   SortTypeParams();
 }