示例#1
0
        private void DecompileClass_Google(IRClass target, out List <TypeDefinition> references)
        {
            // Fetch properties of the type..
            var props = GoogleCSInspector.ExtractClassProperties(_subject, out references);

            // Store properties.
            target.Properties = props;

            // Container of all parsed tags.
            List <ulong> tags = new List <ulong>();
            var          constructEnumeration = _subject.Methods.Where(GoogleCSInspector.MatchStaticConstructor);

            if (!constructEnumeration.Any())
            {
                throw new ExtractionException("No static constructor found!");
            }
            var construct = constructEnumeration.First();
            Action <CallInfo, List <byte> > cctorOnCall = (CallInfo c, List <byte> w) =>
            {
                GoogleCSInspector.StaticCctorOnCall(c, props, tags);
            };
            Action <StoreInfo, List <byte> > cctorOnStore = (StoreInfo s, List <byte> w) =>
            {
                GoogleCSInspector.StaticCctorOnStore(s, props, tags);
            };

            // Walk static constructor method.
            MethodWalker.WalkMethod(construct, cctorOnCall, cctorOnStore);

            // Extract necesary methods for decompilation.
            var serializeEnumeration = _subject.Methods.Where(GoogleCSInspector.MatchSerializeMethod);

            if (!serializeEnumeration.Any())
            {
                throw new ExtractionException("No serialize method found!");
            }

            // Get serialize method.
            var serialize = serializeEnumeration.First();

            // Handler for serialize oncall action.
            Action <CallInfo, List <byte> > googleSerializeOnCall = (CallInfo info, List <byte> w) =>
            {
                // Just chain the call.
                GoogleCSInspector.SerializeOnCall(info, w, props);
            };

            // Walk serialize method.
            MethodWalker.WalkMethod(serialize, googleSerializeOnCall, null);
        }