コード例 #1
0
ファイル: ProofState.cs プロジェクト: ggrov/tacny
        /// <summary>
        /// Initialize a new tactic state
        /// </summary>
        /// <param name="tacAps">Tactic application</param>
        /// <param name="variables">Dafny variables</param>
        public void InitState(UpdateStmt tacAps, Dictionary <IVariable, Dfy.Type> variables)
        {
            // clear the scope
            _scope = new Stack <Frame>();


            var tactic = GetTactic(tacAps) as Tactic;

            var aps = ((ExprRhs)tacAps.Rhss[0]).Expr as ApplySuffix;

            if (aps.Args.Count != tactic.Ins.Count)
            {
                Reporter.Error(MessageSource.Tacny, tacAps.Tok,
                               $"Wrong number of method arguments (got {aps.Args.Count}, expected {tactic.Ins.Count})");
            }

            var frame = new Frame(tactic, Reporter);

            foreach (var item in variables)
            {
                if (!frame.ContainDafnyVar(item.Key.Name))
                {
                    frame.AddDafnyVar(item.Key.Name, new VariableData {
                        Variable = item.Key, Type = item.Value
                    });
                }
                else
                {
                    throw new ArgumentException($"Dafny variable {item.Key.Name} is already declared in the current context");
                }
            }

            for (int index = 0; index < aps.Args.Count; index++)
            {
                var arg = aps.Args[index];
                frame.AddTacnyVar(tactic.Ins[index].Name, arg);
            }

            _scope.Push(frame);
            TacticApplication = tacAps.Copy();
        }
コード例 #2
0
        /// <summary>
        /// Initialize a new tactic state
        /// </summary>
        /// <param name="tacAps">Tactic application</param>
        /// <param name="variables">Dafny variables</param>
        public void InitState(UpdateStmt tacAps, Dictionary <IVariable, Dfy.Type> variables)
        {
            // clear the scope
            _scope = new Stack <Frame>();
            var tactic = GetTactic(tacAps) as Tactic;
            var aps    = ((ExprRhs)tacAps.Rhss[0]).Expr as ApplySuffix;

            if (aps.Args.Count != tactic.Ins.Count)
            {
                Reporter.Error(MessageSource.Tacny, tacAps.Tok,
                               $"Wrong number of method arguments (got {aps.Args.Count}, expected {tactic.Ins.Count})");
            }
            var frame = new Frame(tactic, Reporter);

            for (int index = 0; index < aps.Args.Count; index++)
            {
                var arg = aps.Args[index];
                frame.AddLocalVariable(tactic.Ins[index].Name, arg);
            }

            _scope.Push(frame);
            FillSourceState(variables);
            TacticApplication = tacAps.Copy();
        }
コード例 #3
0
ファイル: ProofState.cs プロジェクト: ggrov/tacny
    /// <summary>
    /// Initialize a new tactic state
    /// </summary>
    /// <param name="tacAps">Tactic application</param>
    /// <param name="variables">Dafny variables</param>
    public void InitState(UpdateStmt tacAps, Dictionary<IVariable, Dfy.Type> variables) {
      // clear the scope  
      _scope = new Stack<Frame>();
      var tactic = GetTactic(tacAps) as Tactic;
      var aps = ((ExprRhs) tacAps.Rhss[0]).Expr as ApplySuffix;
      if (aps.Args.Count != tactic.Ins.Count)
        Reporter.Error(MessageSource.Tacny, tacAps.Tok,
          $"Wrong number of method arguments (got {aps.Args.Count}, expected {tactic.Ins.Count})");
      var frame = new Frame(tactic, Reporter);
      for (int index = 0; index < aps.Args.Count; index++) {
        var arg = aps.Args[index];
        frame.AddLocalVariable(tactic.Ins[index].Name, arg);
      }

      _scope.Push(frame);
      FillSourceState(variables);
      TacticApplication = tacAps.Copy();
    }
コード例 #4
0
ファイル: ProofState.cs プロジェクト: ggrov/tacny
    /// <summary>
    /// Initialize a new tactic state
    /// </summary>
    /// <param name="tacAps">Tactic application</param>
    /// <param name="variables">Dafny variables</param>
    public void InitState(UpdateStmt tacAps, Dictionary<IVariable, Dfy.Type> variables) {
      // clear the scope  
      _scope = new Stack<Frame>();


      var tactic = GetTactic(tacAps) as Tactic;

      var aps = ((ExprRhs)tacAps.Rhss[0]).Expr as ApplySuffix;
      if(aps.Args.Count != tactic.Ins.Count)
        Reporter.Error(MessageSource.Tacny, tacAps.Tok,
          $"Wrong number of method arguments (got {aps.Args.Count}, expected {tactic.Ins.Count})");

      var frame = new Frame(tactic, Reporter);

      foreach(var item in variables) {
        if(!frame.ContainDafnyVar(item.Key.Name))
          frame.AddDafnyVar(item.Key.Name, new VariableData { Variable = item.Key, Type = item.Value });
        else
          throw new ArgumentException($"Dafny variable {item.Key.Name} is already declared in the current context");
      }

      for(int index = 0; index < aps.Args.Count; index++) {
        var arg = aps.Args[index];
        frame.AddTacnyVar(tactic.Ins[index].Name, arg);
      }

      _scope.Push(frame);
      TacticApplication = tacAps.Copy();
    }