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(); }
public override void Write(JavaWriter wtr) { wtr.Write16(wtr.ConstUtf8(tag)); wtr.Fork(); wtr.Write16(frames.Length); for (int i = 0; i < frames.Length; i++) { byte type = frames[i].type; wtr.Write8(type); if (type >= 247) { wtr.Write16(frames[i].deltaOffset); } var locals = frames[i].locals; if (locals == null) { wtr.Write16(0); } else { wtr.Write16(locals.Length); for (int j = 0; j < locals.Length; j++) { byte localType = locals[j].type; wtr.Write8(localType); if (localType >= 7 && localType <= 8) { wtr.Write16(locals[j].extra); } } } var stack = frames[i].stack; if (stack == null) { wtr.Write16(0); } else { wtr.Write16(stack.Length); for (int j = 0; j < stack.Length; j++) { byte stackType = stack[j].type; wtr.Write8(stackType); if (stackType >= 7 && stackType <= 8) { wtr.Write16(stack[j].extra); } } } } wtr.Join(); }
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(); }