示例#1
0
            public override void Write(JavaWriter wtr)
            {
                wtr.Where.Push(tag);
                wtr.Write16(wtr.ConstUtf8(tag));
                wtr.Fork();
                wtr.Write16(maxStack);
                wtr.Write16(maxLocals);
                wtr.Write32((uint)code.Length);
                wtr.WriteBlock(code);

                if (exceptions == null)
                {
                    wtr.Write16(0);
                }
                else
                {
                    wtr.Write16(exceptions.Length);
                    for (int i = 0; i < exceptions.Length; i++)
                    {
                        wtr.Write16(exceptions[i].start);
                        wtr.Write16(exceptions[i].endPlus1);
                        wtr.Write16(exceptions[i].handler);
                        wtr.Write16((exceptions[i].catchType == null) ? 0 :
                                    wtr.ConstClass(exceptions[i].catchType));
                    }
                }

                attributes.Write(wtr);
                wtr.Join();
                wtr.Where.Pop();
            }
示例#2
0
        /*
         * JavaFieldWriter
         */



        public void Write(JavaWriter wtr)
        {
            wtr.Where.Push($"field '{Name}'");

            wtr.Write16((ushort)Flags);
            wtr.Write16(wtr.ConstUtf8(Name));
            wtr.Write16(wtr.ConstUtf8(Type.ToDescriptor()));

            if (Constant != null)
            {
                var attributes = new JavaAttributeSet();
                attributes.Put(new JavaAttribute.ConstantValue(Constant));
                attributes.Write(wtr);
            }
            else
            {
                wtr.Write16(0); // attributes
            }
            wtr.Where.Pop();
        }
示例#3
0
        public void Write(JavaWriter wtr)
        {
            wtr.Where.Push($"method '{Name}'");

            wtr.Write16((ushort)Flags);
            wtr.Write16(wtr.ConstUtf8(Name));
            wtr.Write16(wtr.ConstUtf8(ToDescriptor()));

            var attributes = new JavaAttributeSet();

            if (Code != null)
            {
                var codeAttr = new JavaAttribute.Code();
                Code.Write(wtr, codeAttr);
                attributes.Put(codeAttr);
            }

            attributes.Write(wtr);

            wtr.Where.Pop();
        }
示例#4
0
        public void Write(JavaWriter wtr)
        {
            wtr.Where.Push($"writing class '{Name}'");

            if (Name == null)
            {
                throw wtr.Where.Exception("missing class name");
            }

            wtr.Write16((ushort)Flags);
            wtr.Write16(wtr.ConstClass(Name));
            wtr.Write16(wtr.ConstClass(Super));

            if (Interfaces == null)
            {
                wtr.Write16(0);
            }
            else
            {
                wtr.Write16(Interfaces.Count);
                for (int i = 0; i < Interfaces.Count; i++)
                {
                    wtr.Write16(wtr.ConstClass(Interfaces[i]));
                }
            }

            if (Fields == null)
            {
                wtr.Write16(0);
            }
            else
            {
                wtr.Write16(Fields.Count);
                for (int i = 0; i < Fields.Count; i++)
                {
                    Fields[i].Write(wtr);
                }
            }

            if (Methods == null)
            {
                wtr.Write16(0);
            }
            else
            {
                wtr.Write16(Methods.Count);
                for (int i = 0; i < Methods.Count; i++)
                {
                    Methods[i].Write(wtr);
                }
            }

            var attributes = new JavaAttributeSet();

            if (SourceFile != null)
            {
                attributes.Put(new JavaAttribute.SourceFile(SourceFile));
            }

            if (Signature != null)
            {
                attributes.Put(new JavaAttribute.Signature(Signature));
            }

            WriteInnerClasses(attributes);

            if (wtr.bootstrapMethods != null)
            {
                attributes.Put(wtr.bootstrapMethods);
            }

            attributes.Write(wtr);

            wtr.Where.Pop();
        }