MCPcopy Create free account
hub / github.com/Norbyte/bg3se / EvaluateInServerThread

Method EvaluateInServerThread

BG3Extender/Osiris/Debugger/Debugger.cpp:592–685  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590 }
591
592 ResultCode Debugger::EvaluateInServerThread(uint32_t seq, EvalType type, uint32_t nodeId, MsgTuple const & params,
593 bool & querySucceeded)
594 {
595 DEBUG("Debugger::EvaluateInServerThread(): Type %d, node %d", type, nodeId);
596
597 if (nodeId == 0 || nodeId > (*globals_.Nodes)->Db.Size) {
598 WARN("Debugger::EvaluateInServerThread(): Tried to call nonexistent node %d", nodeId);
599 return ResultCode::InvalidNodeId;
600 }
601
602 auto node = (*globals_.Nodes)->Db.Elements[nodeId - 1];
603 if (node->Function == nullptr) {
604 WARN("Debugger::EvaluateInServerThread(): Node has no function!");
605 return ResultCode::NotCallable;
606 }
607
608 auto const & sig = node->Function->Signature;
609 if (params.column_size() != sig->Params->Params.Size) {
610 WARN("Debugger::EvaluateInServerThread(): Got %d params, but node %d has %d!",
611 params.column_size(), nodeId, (unsigned)sig->Params->Params.Size);
612 return ResultCode::InvalidParamTupleArity;
613 }
614
615 auto typeNode = sig->Params->Params.Head->Next;
616 for (unsigned i = 0; i < sig->Params->Params.Size; i++) {
617 auto typeId = params.column()[i].type_id();
618 if (typeId != (uint32_t)ValueType::None
619 && !AreTypesCompatible(typeNode->Item.Type, typeId)) {
620 WARN("Debugger::EvaluateInServerThread(): Parameter %d type mismatch; expected %d, got %d!",
621 i, typeNode->Item.Type, typeId);
622 return ResultCode::InvalidParamType;
623 }
624 typeNode = typeNode->Next;
625
626 if (typeId == (uint32_t)ValueType::None
627 && type != EvalType::Pushdown
628 && !sig->OutParamList.isOutParam(i)) {
629 WARN("Debugger::EvaluateInServerThread(): Got a null value for IN parameter %d!", i);
630 return ResultCode::MissingRequiredParam;
631 }
632 }
633
634 auto adapter = debugAdapters_.FindAdapter(params.column_size());
635 if (adapter == nullptr) {
636 WARN("Debugger::EvaluateInServerThread(): No debug adapter available for %d columns!", params.column_size());
637 return ResultCode::NoAdapter;
638 }
639
640 breakpoints_.SetDebuggingDisabled(true);
641
642 switch (type)
643 {
644 case EvalType::IsValid:
645 {
646 SmallTuple tuple;
647 MsgToTuple(params, tuple);
648 // Evaluate whether the query succeeds
649 querySucceeded = node->IsValid(&tuple, adapter->Id);

Callers 1

EvaluateMethod · 0.95

Calls 8

AreTypesCompatibleFunction · 0.85
MsgToTupleFunction · 0.85
TupClearOutParamsFunction · 0.85
isOutParamMethod · 0.80
FindAdapterMethod · 0.80
SetDebuggingDisabledMethod · 0.80
SendEvaluateRowMethod · 0.80
IsValidMethod · 0.45

Tested by

no test coverage detected