コード例 #1
0
        private void OnEndDatabaseContents(BkEndDatabaseContents msg)
        {
            var rows = DatabaseContents[msg.DatabaseId];
            var db   = DebugInfo.Databases[msg.DatabaseId];

            var evalResponse = new DAPEvaluateResponse();

            evalResponse.result             = $"Database {db.Name} ({rows.Count} rows)";
            evalResponse.namedVariables     = 0;
            evalResponse.indexedVariables   = rows.Count;
            evalResponse.variablesReference = rows.VariablesReference;

            var requests = PendingDatabaseRequests[msg.DatabaseId];

            foreach (var request in requests)
            {
                DAP.SendReply(request, evalResponse);
            }

            requests.Clear();
        }
コード例 #2
0
        public void EvaluateCall(DAPRequest request, Statement stmt, CoalescedFrame frame, bool allowMutation)
        {
            NodeDebugInfo node;
            var           func = new FunctionNameAndArity(stmt.Name, stmt.Params.Count);

            if (!NameToNodeMap.TryGetValue(func, out node))
            {
                DAP.SendReply(request, "Name not found: " + func);
                return;
            }

            var function = DebugInfo.Functions[node.FunctionName];
            var args     = ParamsToTuple(stmt.Params, frame);

            DbgEvaluate.Types.EvalType evalType;
            switch (node.Type)
            {
            case Node.Type.Database:
                if (stmt.Not)
                {
                    evalType = DbgEvaluate.Types.EvalType.Insert;
                }
                else
                {
                    evalType = DbgEvaluate.Types.EvalType.Delete;
                }
                break;

            case Node.Type.Proc:
                if (stmt.Not)
                {
                    throw new RequestFailedException("\"NOT\" statements not supported for PROCs");
                }

                evalType = DbgEvaluate.Types.EvalType.Insert;
                break;

            case Node.Type.DivQuery:
            case Node.Type.InternalQuery:
            case Node.Type.UserQuery:
                if (stmt.Not)
                {
                    throw new RequestFailedException("\"NOT\" statements not supported for QRYs");
                }

                evalType = DbgEvaluate.Types.EvalType.IsValid;
                break;

            default:
                throw new RequestFailedException($"Eval node type not supported: {node.Type}");
            }

            if ((evalType != DbgEvaluate.Types.EvalType.IsValid ||
                 node.Type == Node.Type.UserQuery) &&
                !allowMutation)
            {
                throw new RequestFailedException($"Evaluation could cause game state change");
            }

            UInt32 seq = DbgClient.SendEvaluate(evalType, node.Id, args);

            var argNames = function.Params.Select(arg => arg.Name).ToList();
            var eval     = new PendingExpressionEvaluation
            {
                Request  = request,
                Results  = EvalResults.MakeResults(function.Params.Count, argNames),
                Node     = node,
                Function = function
            };

            PendingEvaluations.Add(seq, eval);
        }
コード例 #3
0
 private void MessageReceived(DAPMessage message)
 {
     if (message is DAPRequest)
     {
         try
         {
             HandleRequest(message as DAPRequest);
         }
         catch (RequestFailedException e)
         {
             Stream.SendReply(message as DAPRequest, e.Message);
         }
         catch (Exception e)
         {
             LogError(e.ToString());
             Stream.SendReply(message as DAPRequest, e.ToString());
         }
     }
     else if (message is DAPEvent)
     {
         HandleEvent(message as DAPEvent);
     }
     else
     {
         throw new InvalidDataException("DAP replies not handled");
     }
 }