Пример #1
0
        public static Method GetMethod(Class c, CompileMethodInfo method, List<CompileConstant> constants)
        {
            var m = new Method
                        {
                            DeclaringType = c,
                            Name = GetUtf8(method.Name, constants),
                            Modifiers = method.Modifiers,
                        };

            string methodDescriptor = GetUtf8(method.Descriptor, constants);
            Tuple<List<Type>, Type> methodTypes = GetMethodTypeFromDescriptor(methodDescriptor);

            m.Parameters.AddRange(methodTypes.Item1.Select(x => new Method.Parameter { Type = x }));
            m.ReturnType = methodTypes.Item2;

            return m;
        }
Пример #2
0
        public CompileMethodInfo Compile(CompileManager manager)
        {
            method.Resolve(manager.Imports);

            var methodInfo = new CompileMethodInfo();

            short nameIndex = manager.AddConstantUtf8(method.Name);
            short descriptorIndex = manager.AddConstantUtf8(method.GetDescriptor());

            CompileBody(manager);

            methodInfo.Modifiers = method.Modifiers;
            methodInfo.Name = nameIndex;
            methodInfo.Descriptor = descriptorIndex;
            methodInfo.Attributes = attributes; //TODO: Code, Exceptions, Synthetic, Deprecated

            return methodInfo;
        }
Пример #3
0
 public void AddMethod(CompileMethodInfo method)
 {
     Methods.Add(method);
 }
Пример #4
0
        private void ReadMethods(EndianBinaryReader reader)
        {
            var methodCount = reader.ReadInt16();

            for (var i = 0; i < methodCount; i++)
            {
                var method = new CompileMethodInfo();

                method.Modifiers = (Modifier)reader.ReadInt16();
                method.Name = reader.ReadInt16();
                method.Descriptor = reader.ReadInt16();

                method.Attributes.AddRange(ReadAttributes(reader));

                Methods.Add(method);
            }
        }
Пример #5
0
        private static IEnumerable<CompileMethodInfo> ReadMethods(EndianBinaryReader reader, List<CompileConstant> constants)
        {
            short methodCount = reader.ReadInt16();
            var methods = new CompileMethodInfo[methodCount];

            for (int i = 0; i < methodCount; i++)
            {
                var method = new CompileMethodInfo();

                method.Modifiers = (Modifier)reader.ReadInt16();
                method.Name = reader.ReadInt16();
                method.Descriptor = reader.ReadInt16();

                method.Attributes.AddRange(ReadAttributes(reader, constants));

                methods[i] = method;
            }

            return methods;
        }