MCPcopy Create free account
hub / github.com/ReadyTalk/avian / makeTestCode

Method makeTestCode

test/Subroutine.java:35–88  ·  view source on GitHub ↗
(List pool)

Source from the content-addressed store, hash-verified

33 }
34
35 private static byte[] makeTestCode(List pool) throws IOException {
36 ByteArrayOutputStream out = new ByteArrayOutputStream();
37 Stream.write2(out, 1); // max stack
38 Stream.write2(out, 1); // max locals
39 Stream.write4(out, 0); // length (we'll set the real value later)
40
41 // 0:
42 Stream.write1(out, Assembler.ldc_w);
43 Stream.write2(out, ConstantPool.addString(pool, "foo") + 1);
44
45 // 3:
46 Stream.write1(out, Assembler.astore_0);
47
48 // 4:
49 Stream.write1(out, Assembler.invokestatic);
50 Stream.write2(out, ConstantPool.addMethodRef
51 (pool, "java/lang/System", "gc", "()V") + 1);
52
53 // 7:
54 Stream.write1(out, Assembler.goto_);
55 Stream.write2(out, 9); // 16
56
57 // 10:
58 Stream.write1(out, Assembler.astore_0);
59
60 // 11:
61 Stream.write1(out, Assembler.invokestatic);
62 Stream.write2(out, ConstantPool.addMethodRef
63 (pool, "java/lang/System", "gc", "()V") + 1);
64
65 // 14:
66 Stream.write1(out, Assembler.ret);
67 Stream.write1(out, 0);
68
69 // 16:
70 Stream.write1(out, Assembler.jsr);
71 Stream.write2(out, -6); // 10
72
73 // 19:
74 Stream.write1(out, Assembler.invokestatic);
75 Stream.write2(out, ConstantPool.addMethodRef
76 (pool, "java/lang/System", "gc", "()V") + 1);
77
78 // 22:
79 Stream.write1(out, Assembler.return_);
80
81 Stream.write2(out, 0); // exception handler table length
82 Stream.write2(out, 0); // attribute count
83
84 byte[] result = out.toByteArray();
85 Stream.set4(result, 4, result.length - 12);
86
87 return result;
88 }
89
90 private static Class makeTestClass() throws IOException {
91 List pool = new ArrayList();

Callers 1

makeTestClassMethod · 0.95

Calls 7

write2Method · 0.95
write4Method · 0.95
write1Method · 0.95
addStringMethod · 0.95
addMethodRefMethod · 0.95
toByteArrayMethod · 0.95
set4Method · 0.95

Tested by

no test coverage detected