Beispiel #1
0
 private static void DebugNodes(IEnumerable <AstToken> parents)
 {
     foreach (var par in parents)
     {
         try
         {
             var json       = par.SerializeFriendly();
             var translated = AstTranslator.GetFunctionBody(par);
             // Debugger.Break();
         }
         catch (Exception e)
         {
         }
     }
 }
        public void VisitTest(AstToken token)
        {
            if (token.Type == AstType.ForStmt)
            {
                Console.WriteLine("For statement");
            }

            foreach (var child in token.children)
            {
                VisitTest(child);
            }

            if (IsPacketShiftExpression(token))
            {
                //Type from token.children[0]
                //
                //|-CXXOperatorCallExpr 0x1f38c6b5468 <line:2997:2, line:3005:6> 'CPacket' lvalue '<<'
                //| |-ImplicitCastExpr 0x1f38c6b5450 <col:3> 'CPacket &(*)(int)' <FunctionToPointerDecay>
                //| | `-DeclRefExpr 0x1f38c6b5430 <col:3> 'CPacket &(int)' lvalue CXXMethod 0x1f386e73ac8 'operator<<' 'CPacket &(int)'
                if (TryGetPacketWriteOverloadType(token.children[0], out var typeName))
                {
                    Console.Write($"Write type : {typeName} Name: ");
                }
                else
                {
                    Console.WriteLine("Write type not found!");
                    Debugger.Break();
                    return;
                }

                if (token.children.Count < 2)
                {
                    Console.WriteLine("Unhandled: children count is smaller than expected!");
                    Debugger.Break();
                    return;
                }

                var instructionvisitor = new InstructionVisitor(token.children[2]);
                var executionResult    = instructionvisitor.Execute();
                if (!executionResult)
                {
                    Console.WriteLine("Unknown");

                    var bdy      = AstTranslator.GetFunctionBody(token.children[2]);
                    var relevant = token.AsTokenDto();
                    relevant.Children[1] = new AstTokenDto();
                    var reser = relevant.SerializeFriendly();


                    Debugger.Break();
                }



                //if (token.children.Count > 1 && TryGetSimpleWriteFromVar(token.children[2], out var prop))
                //{
                //    Console.Write(prop.Name);

                //    //var callPart = token.children[0].SerializeFriendly();

                //    //Debugger.Break();
                //}
                //else if (TryGetMethodCallWrite(token.children[2], out var name))
                //{
                //    //Debugger.Break();

                //    Console.Write(name);
                //}
                //else if (TryParseSizeAccessor(token.children[2]))
                //{
                //    //Debugger.Break();
                //}
                //else
                //{
                //    Console.Write("Unknown");

                //    var bdy = AstTranslator.GetFunctionBody(token.children[2]);
                //    var relevant = token.AsTokenDto();
                //    relevant.Children[1] = new AstTokenDto();
                //    var reser = relevant.SerializeFriendly();

                //    Debugger.Break();
                //}

                //var accessor = GetChildAccesor(token.children[2]);
                Console.WriteLine();
            }
        }