Beispiel #1
0
 public unsafe static void DumpFunctionToCSV(string name, string filename)
 {
     using (FileStream fileStream = File.Open(filename, FileMode.Create, FileAccess.Write, FileShare.Write))
         using (StreamWriter streamWriter = new StreamWriter(fileStream))
         {
             VirtualMachine *ptr  = *GameFunctions.GetThreadLocalStorage()->Jass.AsUnsafe()->VirtualMachine;
             HT_Node *       ptr2 = ptr->FunctionTable->Lookup(name);
             if (ptr2 != null)
             {
                 OpCode *value = (OpCode *)ptr2->Value;
                 string  text  = string.Empty;
                 int     num   = -1;
                 while (value[num].OpType != OpCodeType.EndFunction)
                 {
                     text = $"{text}0x{num + 1:X4}{ByteCodeToString(value + num, ";")}{Environment.NewLine}";
                     num++;
                 }
                 streamWriter.WriteLine(text);
                 Trace.WriteLine($"Function '{name}' dumped to '{filename}'");
             }
             else
             {
                 Trace.WriteLine($"Function '{name}' could not be found!");
             }
         }
 }
Beispiel #2
0
        public unsafe void *LookupValue(string key)
        {
            HT_Node *htNodePtr = this.Lookup(key);

            if ((IntPtr)htNodePtr == IntPtr.Zero)
            {
                return((void *)null);
            }
            return(htNodePtr->Value);
        }
Beispiel #3
0
        public unsafe bool ContainsKey(string key)
        {
            if (string.IsNullOrEmpty(key) || this.Bitmask == -1)
            {
                return(false);
            }
            int num = SStr.HashHT(key);

            for (HT_Node *htNodePtr = this.Buckets[this.Bitmask & num].List; (int)htNodePtr > 0; htNodePtr = htNodePtr->Next)
            {
                if (num == htNodePtr->Hash && key == htNodePtr->Key.AsString())
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #4
0
        public unsafe HT_Node *Lookup(string key)
        {
            if (string.IsNullOrEmpty(key) || this.Bitmask == -1)
            {
                return((HT_Node *)null);
            }
            int num = SStr.HashHT(key);

            for (HT_Node *htNodePtr = this.Buckets[this.Bitmask & num].List; (int)htNodePtr > 0; htNodePtr = htNodePtr->Next)
            {
                if (num == htNodePtr->Hash && key == htNodePtr->Key.AsString())
                {
                    return(htNodePtr);
                }
            }
            return((HT_Node *)null);
        }
Beispiel #5
0
        public unsafe HT_Node *[] GetAllValues()
        {
            List <IntPtr> numList     = new List <IntPtr>();
            int           bucketCount = this.BucketCount;

            for (int index = 0; index < bucketCount; ++index)
            {
                for (HT_Node *htNodePtr = this.Buckets[index].List; (int)htNodePtr > 0; htNodePtr = htNodePtr->Next)
                {
                    numList.Add((IntPtr)((void *)htNodePtr));
                }
            }
            HT_Node *[] htNodePtrArray = new HT_Node *[numList.Count];
            for (int index = 0; index < htNodePtrArray.Length; ++index)
            {
                htNodePtrArray[index] = (HT_Node *)(void *)numList[index];
            }
            return(htNodePtrArray);
        }
Beispiel #6
0
        public unsafe static void DumpFunctionToTrace(string name)
        {
            VirtualMachine *ptr  = *GameFunctions.GetThreadLocalStorage()->Jass.AsUnsafe()->VirtualMachine;
            HT_Node *       ptr2 = ptr->FunctionTable->Lookup(name);

            if (ptr2 != null)
            {
                OpCode *value = (OpCode *)ptr2->Value;
                string  text  = string.Empty;
                int     num   = -1;
                while (value[num].OpType != OpCodeType.EndFunction)
                {
                    text = $"{text}0x{num + 1:X4}{ByteCodeToString(value + num, "\t")}{Environment.NewLine}";
                    num++;
                }
                Trace.WriteLine(text);
                Trace.WriteLine($"Function '{name}'");
            }
            else
            {
                Trace.WriteLine($"Function '{name}' could not be found!");
            }
        }