Check-in [774f00f698]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add base call for decoding the physical pool.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 774f00f698f03e5c026c9fa68883a7c4c69cec7b
User & Date: stephanie.gawroriski 2019-09-07 18:42:20
Context
2019-09-07
20:24
Base outer logic for decoding dual pools. check-in: 0e7c79e38d user: stephanie.gawroriski tags: trunk
18:42
Add base call for decoding the physical pool. check-in: 774f00f698 user: stephanie.gawroriski tags: trunk
18:02
Add method do decode a dual pool that inherits from the JAR or ROM. check-in: 8207280857 user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to runt/libs/tool-classfile/dev/shadowtail/classfile/mini/DualPoolEncoder.java.

5
6
7
8
9
10
11

12
13

14
15
16

17
18
19
20
21
22
23
..
33
34
35
36
37
38
39




















40
41
42
43
44
45
46
...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;


import dev.shadowtail.classfile.pool.BasicPoolBuilder;
import dev.shadowtail.classfile.pool.BasicPoolEntry;

import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

import java.io.IOException;
import java.io.OutputStream;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * This contains the encoder and decoder for dual pools.
 *
................................................................................
	 * Not used.
	 *
	 * @since 2019/07/17
	 */
	private DualPoolEncoder()
	{
	}




















	
	/**
	 * Encodes the dual pool to the given output stream and returns the
	 * result.
	 *
	 * @param __dp The dual-pool to encode.
	 * @param __out The stream to write to.
................................................................................
		}
		
		// Write the encoded pool
		table.writeTo(__out);
		
		// Return the positions of everything
		return new DualPoolEncodeResult(
			table.sectionAddress(sl), table.sectionSize(sl),
			table.sectionAddress(rl), table.sectionSize(rl));
	}
	
	/**
	 * Encodes the pool value.
	 *
	 * @param __t The type to encode.
	 * @param __p The parts.







>


>



>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
|







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
..
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
...
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.BasicPool;
import dev.shadowtail.classfile.pool.BasicPoolBuilder;
import dev.shadowtail.classfile.pool.BasicPoolEntry;
import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * This contains the encoder and decoder for dual pools.
 *
................................................................................
	 * Not used.
	 *
	 * @since 2019/07/17
	 */
	private DualPoolEncoder()
	{
	}
	
	/**
	 * Decodes the specified pool.
	 *
	 * @param __cl The input stream for the class pool.
	 * @param __rt The input stream for the run-time pool.
	 * @return The resulting dual pool.
	 * @throws IOException If the pool could not be read.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/07
	 */
	public static final DualClassRuntimePool decode(InputStream __cl,
		InputStream __rt)
		throws IOException, NullPointerException
	{
		if (__cl == null || __rt == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Encodes the dual pool to the given output stream and returns the
	 * result.
	 *
	 * @param __dp The dual-pool to encode.
	 * @param __out The stream to write to.
................................................................................
		}
		
		// Write the encoded pool
		table.writeTo(__out);
		
		// Return the positions of everything
		return new DualPoolEncodeResult(
			table.sectionAddress(sl), -table.sectionSize(sl),
			table.sectionAddress(rl), -table.sectionSize(rl));
	}
	
	/**
	 * Encodes the pool value.
	 *
	 * @param __t The type to encode.
	 * @param __p The parts.

Changes to runt/libs/tool-classfile/dev/shadowtail/classfile/mini/MinimizedClassFile.java.

432
433
434
435
436
437
438
439
440
441





442











443
444
445
446
447
448
449
				(endmagic = (((__is[fsz - 4] & 0xFF) << 24) |
				((__is[fsz - 3] & 0xFF) << 16) |
				((__is[fsz - 2] & 0xFF) << 8) |
				(__is[fsz - 1] & 0xFF))))
				throw new InvalidClassFormatException(
					String.format("JC02 %08x", endmagic));
			
			// Read constant pool
			DualClassRuntimePool pool = null;
			if (true)





				throw new todo.TODO();











			
			// Read static and instance fields
			MinimizedField[] sfields = MinimizedField.decodeFields(
					header.sfcount, pool, __is, header.sfoff, header.sfsize),
				ifields = MinimizedField.decodeFields(
					header.ifcount, pool, __is, header.ifoff, header.ifsize);
			







|
|
|
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>







432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
				(endmagic = (((__is[fsz - 4] & 0xFF) << 24) |
				((__is[fsz - 3] & 0xFF) << 16) |
				((__is[fsz - 2] & 0xFF) << 8) |
				(__is[fsz - 1] & 0xFF))))
				throw new InvalidClassFormatException(
					String.format("JC02 %08x", endmagic));
			
			// Virtual constant pool which relies on a parent one
			DualClassRuntimePool pool;
			if (header.staticpoolsize < 0 || header.runtimepoolsize < 0)
			{
				// {@squirreljme.error JC4h No parent pool was specified.}
				if (__ppool == null)
					throw new NullPointerException("JC4h");
				
				throw new todo.TODO();
			}
			
			// Decode physical pool within the class
			else
			{
				pool = DualPoolEncoder.decode(
					new ByteArrayInputStream(__is, header.staticpooloff,
						header.staticpoolsize),
					new ByteArrayInputStream(__is, header.runtimepooloff,
						header.runtimepoolsize));
			}
			
			// Read static and instance fields
			MinimizedField[] sfields = MinimizedField.decodeFields(
					header.sfcount, pool, __is, header.sfoff, header.sfsize),
				ifields = MinimizedField.decodeFields(
					header.ifcount, pool, __is, header.ifoff, header.ifsize);