Пример #1
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();
        }
Пример #2
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();
        }
Пример #3
0
            public override void Write(JavaWriter wtr)
            {
                int length = sizeof(ushort) // classes.Length
                             + classes.Length * sizeof(ushort) * 4;

                Write(wtr, tag, length);
                wtr.Write16(classes.Length);
                for (int i = 0; i < classes.Length; i++)
                {
                    wtr.Write16(wtr.ConstClass(classes[i].InnerLongName));
                    ushort v = (classes[i].OuterLongName == null) ? (ushort)0
                             : wtr.ConstClass(classes[i].OuterLongName);
                    wtr.Write16(v);
                    v = (classes[i].InnerShortName == null) ? (ushort)0
                      : wtr.ConstUtf8(classes[i].InnerShortName);
                    wtr.Write16(v);
                    wtr.Write16((ushort)classes[i].Flags);
                }
            }
Пример #4
0
 public override void Write(JavaWriter wtr)
 {
     Write(wtr, tag, sizeof(ushort));
     wtr.Write16(wtr.ConstUtf8(descriptor));
 }
Пример #5
0
            public override void Write(JavaWriter wtr)
            {
                wtr.Write16(wtr.ConstUtf8(tag));
                wtr.Fork();
                wtr.Write16(methods.Length);
                for (int i = 0; i < methods.Length; i++)
                {
                    wtr.Write16(wtr.ConstMethodHandle(methods[i].mh));
                    var args = methods[i].args;
                    wtr.Write16(args.Length);
                    for (int j = 0; j < args.Length; j++)
                    {
                        ushort constantIndex;
                        var    value = args[j];

                        if (value is int intValue)
                        {
                            constantIndex = wtr.ConstInteger(intValue);
                        }

                        else if (value is float floatValue)
                        {
                            constantIndex = wtr.ConstFloat(floatValue);
                        }

                        else if (value is long longValue)
                        {
                            constantIndex = wtr.ConstLong(longValue);
                        }

                        else if (value is double doubleValue)
                        {
                            constantIndex = wtr.ConstDouble(doubleValue);
                        }

                        else if (value is JavaType classValue)
                        {
                            constantIndex = wtr.ConstClass(classValue);
                        }

                        else if (value is string stringValue)
                        {
                            constantIndex = wtr.ConstString(stringValue);
                        }

                        else if (value is JavaMethodHandle methodHandleValue)
                        {
                            constantIndex = wtr.ConstMethodHandle(methodHandleValue);
                        }

                        else if (value is JavaMethodType methodTypeValue)
                        {
                            constantIndex = wtr.ConstMethodType(methodTypeValue);
                        }
                        else
                        {
                            throw wtr.Where.Exception($"invalid constant value");
                        }

                        wtr.Write16(constantIndex);
                    }
                }
                wtr.Join();
            }
Пример #6
0
 public override void Write(JavaWriter wtr)
 {
     Write(wtr, tag, sizeof(ushort));
     wtr.Write16(wtr.ConstUtf8(fileName));
 }
Пример #7
0
 public static void Write(JavaWriter wtr, string name, int length)
 {
     wtr.Write16(wtr.ConstUtf8(name));
     wtr.Write32((uint)length);
 }