Check-in [1009b5d68e]

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

Overview
Comment:Some base work on creating class infos.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip-springcoat-bringup
Files: files | file ages | folders
SHA1: 1009b5d68ee14be4c5f8d3807c62db0fa4bb5ae6
User & Date: stephanie.gawroriski 2020-05-13 23:41:48
Context
2020-05-13
23:48
Do not use array form of printing anymore. check-in: 8c97c048af user: stephanie.gawroriski tags: wip-springcoat-bringup
23:41
Some base work on creating class infos. check-in: 1009b5d68e user: stephanie.gawroriski tags: wip-springcoat-bringup
19:54
Minor work. check-in: 0bdf0d6e2c user: stephanie.gawroriski tags: wip-springcoat-bringup
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to emulators/emulator-base/src/main/java/cc/squirreljme/emulator/EmulatorAssembly.java.

6
7
8
9
10
11
12


13

14

15
16
17
18
19
20
21
..
68
69
70
71
72
73
74


75
76
77

78
79
80
81
82
83
84
..
85
86
87
88
89
90
91
































92
93
94
95
96
97
98
...
136
137
138
139
140
141
142
143





144
145
146
147
148
149
150
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.emulator;

import cc.squirreljme.emulator.fb.NativeFramebuffer;


import cc.squirreljme.jvm.Constants;

import cc.squirreljme.jvm.SystemCallError;

import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This contains the implementation of some system calls in the event that the
................................................................................
					// Always succeeds
					context.setError(__si, 0);
					
					// Depends on the system call requested
					switch (__a)
					{
							// Implemented here


						case SystemCallIndex.ERROR_GET:
						case SystemCallIndex.ERROR_SET:
						case SystemCallIndex.FRAMEBUFFER:

						case SystemCallIndex.QUERY_INDEX:
						case SystemCallIndex.TIME_MILLI_WALL:
						case SystemCallIndex.TIME_NANO_MONO:
						case SystemCallIndex.DEBUG_FLAGS:
						case SystemCallIndex.PD_OF_STDERR:
						case SystemCallIndex.PD_OF_STDOUT:
						case SystemCallIndex.PD_WRITE_BYTE:
................................................................................
							return 1;
						
							// Not-implemented
						default:
							return 0;
					}
				}
































				
				// Debugging flags
			case SystemCallIndex.DEBUG_FLAGS:
				{
					int rv = 0;
					
					// {@squirreljme.property cc.squirreljme.debug Set to a
................................................................................
					return oldError;
				}
			
				// Access the framebuffer
			case SystemCallIndex.FRAMEBUFFER:
				return NativeFramebuffer.getInstance().systemCall(context,
					__a, __b, __c, __d, __e, __f, __g, __h);
					





				// Descriptor of standard error
			case SystemCallIndex.PD_OF_STDERR:
				context.setError(__si, 0);
				return 2;
				
				// Descriptor of standard output
			case SystemCallIndex.PD_OF_STDOUT:







>
>

>

>







 







>
>



>







 







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







 







|
>
>
>
>
>







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
...
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.emulator;

import cc.squirreljme.emulator.fb.NativeFramebuffer;
import cc.squirreljme.jvm.ConfigRomKey;
import cc.squirreljme.jvm.ConfigRomType;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.LineEndingType;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallException;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This contains the implementation of some system calls in the event that the
................................................................................
					// Always succeeds
					context.setError(__si, 0);
					
					// Depends on the system call requested
					switch (__a)
					{
							// Implemented here
						case SystemCallIndex.CONFIG_GET_TYPE:
						case SystemCallIndex.CONFIG_GET_VALUE:
						case SystemCallIndex.ERROR_GET:
						case SystemCallIndex.ERROR_SET:
						case SystemCallIndex.FRAMEBUFFER:
						case SystemCallIndex.FRAME_TASK_ID_GET:
						case SystemCallIndex.QUERY_INDEX:
						case SystemCallIndex.TIME_MILLI_WALL:
						case SystemCallIndex.TIME_NANO_MONO:
						case SystemCallIndex.DEBUG_FLAGS:
						case SystemCallIndex.PD_OF_STDERR:
						case SystemCallIndex.PD_OF_STDOUT:
						case SystemCallIndex.PD_WRITE_BYTE:
................................................................................
							return 1;
						
							// Not-implemented
						default:
							return 0;
					}
				}
				
				// Get configuration type
			case SystemCallIndex.CONFIG_GET_TYPE:
				switch (__a)
				{
					case ConfigRomKey.LINE_ENDING:
						return ConfigRomType.INTEGER;
					
					default:
						context.setError(__si,
							SystemCallError.NO_SUCH_CONFIG_KEY);
						return 0;
				}
			
				// Get raw value
			case SystemCallIndex.CONFIG_GET_VALUE:
				switch (__a)
				{
					case ConfigRomKey.LINE_ENDING:
						switch (System.getProperty("line.ending"))
						{
							case "\r":		return LineEndingType.CR;
							case "\r\n":	return LineEndingType.CRLF;
							case "\n":		return LineEndingType.LF;
							default:		return LineEndingType.UNSPECIFIED;
						}
						
					default:
						context.setError(__si,
							SystemCallError.NO_SUCH_CONFIG_KEY);
						return 0;
				}
				
				// Debugging flags
			case SystemCallIndex.DEBUG_FLAGS:
				{
					int rv = 0;
					
					// {@squirreljme.property cc.squirreljme.debug Set to a
................................................................................
					return oldError;
				}
			
				// Access the framebuffer
			case SystemCallIndex.FRAMEBUFFER:
				return NativeFramebuffer.getInstance().systemCall(context,
					__a, __b, __c, __d, __e, __f, __g, __h);
			
				// Always return a task ID of zero since this is the core
				// emulator and it does not really make sense here
			case SystemCallIndex.FRAME_TASK_ID_GET:
				return 0;
				
				// Descriptor of standard error
			case SystemCallIndex.PD_OF_STDERR:
				context.setError(__si, 0);
				return 2;
				
				// Descriptor of standard output
			case SystemCallIndex.PD_OF_STDOUT:

Changes to emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/MemoryManager.java.

347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
...
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
	@Override
	public byte read(long __addr)
		throws MemoryAccessException
	{
		if (__addr < 0 || __addr > Integer.MAX_VALUE)
			throw new MemoryAccessException(__addr, "Read out of bounds.");
		
		Debugging.debugNote("read: %08x", __addr);
		
		// Get entry where the chunk would be located
		Map.Entry<Integer, ReadableByteMemory> chunk =
			this._read.floorEntry((int)__addr);
		if (chunk == null)
			throw new MemoryAccessException(__addr,
				String.format("Unmapped read: %08x", __addr));
................................................................................
	@Override
	public void write(long __addr, byte __v)
		throws MemoryAccessException
	{
		if (__addr < 0 || __addr > Integer.MAX_VALUE)
			throw new MemoryAccessException(__addr, "Write out of bounds.");
		
		Debugging.debugNote("write: %08x <- %d", __addr, __v);
		
		// Get entry where the chunk would be located
		Map.Entry<Integer, WritableByteMemory> chunk =
			this._write.floorEntry((int)__addr);
		if (chunk == null)
			throw new MemoryAccessException(__addr,
				String.format("Unmapped write: %08x", __addr));







|







 







|







347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
...
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
	@Override
	public byte read(long __addr)
		throws MemoryAccessException
	{
		if (__addr < 0 || __addr > Integer.MAX_VALUE)
			throw new MemoryAccessException(__addr, "Read out of bounds.");
		
		//Debugging.debugNote("read: %08x", __addr);
		
		// Get entry where the chunk would be located
		Map.Entry<Integer, ReadableByteMemory> chunk =
			this._read.floorEntry((int)__addr);
		if (chunk == null)
			throw new MemoryAccessException(__addr,
				String.format("Unmapped read: %08x", __addr));
................................................................................
	@Override
	public void write(long __addr, byte __v)
		throws MemoryAccessException
	{
		if (__addr < 0 || __addr > Integer.MAX_VALUE)
			throw new MemoryAccessException(__addr, "Write out of bounds.");
		
		//Debugging.debugNote("write: %08x <- %d", __addr, __v);
		
		// Get entry where the chunk would be located
		Map.Entry<Integer, WritableByteMemory> chunk =
			this._write.floorEntry((int)__addr);
		if (chunk == null)
			throw new MemoryAccessException(__addr,
				String.format("Unmapped write: %08x", __addr));

Changes to emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringMachine.java.

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
..
58
59
60
61
62
63
64

65
66
67

68
69
70
71
72
73
74
..
95
96
97
98
99
100
101

102
103
104
105
106
107
108
...
251
252
253
254
255
256
257












258
259
260
261
262
263
264
import cc.squirreljme.runtime.cldc.io.CodecFactory;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.vm.springcoat.exceptions.SpringFatalException;
import cc.squirreljme.vm.springcoat.exceptions.SpringMachineExitException;
import cc.squirreljme.vm.springcoat.exceptions.SpringVirtualMachineException;
import java.io.File;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
................................................................................
		new MethodNameAndType("__sysBoot", "(JIJI)V");
	
	/** Lock. */
	public final Object strlock =
		new Object();
	
	/** The class loader. */

	protected final SpringClassLoader classloader;
	
	/** Resources accessor. */

	protected final VMResourceAccess resourceaccessor;
	
	/** The class to start execution within. */
	protected final String mainClass;
	
	/** The manager for suites. */
	protected final VMSuiteManager suites;
................................................................................
	
	/** Class names by their objects. */
	@Deprecated
	private final Map<SpringObject, ClassName> _namesbyclass =
		new HashMap<>();
	
	/** Class informations. */

	final Map<ClassName, SpringObject> _classInfos =
		new TreeMap<>();
	
	/** Main entry point arguments. */
	private final String[] _args;
	
	/** System properties. */
................................................................................
		// Allocate RAM for data storage
		MemoryManager mmu = this.tasks.memory;
		SpringPointer baseRam = mmu.attachRam(SpringMachine.DEFAULT_RAM_SIZE);
		
		// Thread that will be used as the main thread of execution, also used
		// to initialize classes when they are requested
		SpringThread mainThread = this.tasks.hardwareThreads.createThread();












		
		// We will be using the same logic in the thread worker if we need to
		// initialize any objects or arguments
		SpringThreadWorker mainWorker = new SpringThreadWorker(this,
			mainThread);
		mainThread._worker = mainWorker;
		







<

<







 







>



>







 







>







 







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







23
24
25
26
27
28
29

30

31
32
33
34
35
36
37
..
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
..
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
...
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
import cc.squirreljme.runtime.cldc.io.CodecFactory;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.vm.springcoat.exceptions.SpringFatalException;
import cc.squirreljme.vm.springcoat.exceptions.SpringMachineExitException;
import cc.squirreljme.vm.springcoat.exceptions.SpringVirtualMachineException;
import java.io.File;
import java.io.PrintStream;

import java.util.HashMap;

import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
................................................................................
		new MethodNameAndType("__sysBoot", "(JIJI)V");
	
	/** Lock. */
	public final Object strlock =
		new Object();
	
	/** The class loader. */
	@Deprecated
	protected final SpringClassLoader classloader;
	
	/** Resources accessor. */
	@Deprecated
	protected final VMResourceAccess resourceaccessor;
	
	/** The class to start execution within. */
	protected final String mainClass;
	
	/** The manager for suites. */
	protected final VMSuiteManager suites;
................................................................................
	
	/** Class names by their objects. */
	@Deprecated
	private final Map<SpringObject, ClassName> _namesbyclass =
		new HashMap<>();
	
	/** Class informations. */
	@Deprecated
	final Map<ClassName, SpringObject> _classInfos =
		new TreeMap<>();
	
	/** Main entry point arguments. */
	private final String[] _args;
	
	/** System properties. */
................................................................................
		// Allocate RAM for data storage
		MemoryManager mmu = this.tasks.memory;
		SpringPointer baseRam = mmu.attachRam(SpringMachine.DEFAULT_RAM_SIZE);
		
		// Thread that will be used as the main thread of execution, also used
		// to initialize classes when they are requested
		SpringThread mainThread = this.tasks.hardwareThreads.createThread();
		mainThread.initializeContext();
		
		// The bootstrap itself must always have the CLDC-Compact library
		// in it in order to properly work.
		VMSuiteManager suites = this.suites;
		for (String libName : suites.listLibraryNames())
			if (libName.toLowerCase().contains("cldc-compact"))
			{
				mainThread.context().pushClassPath(
					suites.loadLibrary(libName));
				break;
			}
		
		// We will be using the same logic in the thread worker if we need to
		// initialize any objects or arguments
		SpringThreadWorker mainWorker = new SpringThreadWorker(this,
			mainThread);
		mainThread._worker = mainWorker;
		

Changes to emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringThreadWorker.java.

1100
1101
1102
1103
1104
1105
1106





1107
1108
1109
1110
1111
1112
1113
		// Depends on the function
		switch (__name.toString())
		{
				// Atomic ticker value
			case "atomicTicker":
				return AtomicTicker.next();
				





				// Lock the garbage collector
			case "gcLock":
				return machine.tasks.gcLock.lock((Integer)__args[0]);
			
				// Unlock the garbage collector
			case "gcUnlock":
				machine.tasks.gcLock.unlock((Integer)__args[0]);







>
>
>
>
>







1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
		// Depends on the function
		switch (__name.toString())
		{
				// Atomic ticker value
			case "atomicTicker":
				return AtomicTicker.next();
				
				// Long's classInfo
			case "classInfoOfLong":
				return this.thread.context().loadClassInfo(this,
					ClassName.fromPrimitiveType(PrimitiveType.LONG)).pointer();
				
				// Lock the garbage collector
			case "gcLock":
				return machine.tasks.gcLock.lock((Integer)__args[0]);
			
				// Unlock the garbage collector
			case "gcUnlock":
				machine.tasks.gcLock.unlock((Integer)__args[0]);

Changes to emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SystemCallHandler.java.

10
11
12
13
14
15
16

17
18
19
20
21
22
23
...
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
package cc.squirreljme.vm.springcoat;

import cc.squirreljme.emulator.AbstractSystemCallHandler;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallException;
import cc.squirreljme.jvm.SystemCallIndex;

import cc.squirreljme.vm.springcoat.exceptions.SpringVirtualMachineException;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;
import net.multiphasicapps.classfile.PrimitiveType;

................................................................................
							error = SystemCallError.PIPE_DESCRIPTOR_INVALID;
							return 0;
					}
					return 1;
				
					// System call not supported
				default:
					System.err.printf("Un-handled sysCall#%d(%d, %d, %d, " +
						"%d, %d, %d, %d, %d)%n",
						__sid, __a, __b, __c, __d, __e, __f, __g, __h);
					
					error = SystemCallError.UNSUPPORTED_SYSTEM_CALL;
					return 0;
			}
		}
		







>







 







|
|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
package cc.squirreljme.vm.springcoat;

import cc.squirreljme.emulator.AbstractSystemCallHandler;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallException;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.vm.springcoat.exceptions.SpringVirtualMachineException;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;
import net.multiphasicapps.classfile.PrimitiveType;

................................................................................
							error = SystemCallError.PIPE_DESCRIPTOR_INVALID;
							return 0;
					}
					return 1;
				
					// System call not supported
				default:
					Debugging.debugNote("Un-handled sysCall#%d(%d, " +
						"%d, %d, %d, %d, %d, %d, %d)%n",
						__sid, __a, __b, __c, __d, __e, __f, __g, __h);
					
					error = SystemCallError.UNSUPPORTED_SYSTEM_CALL;
					return 0;
			}
		}
		

Changes to emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/ThreadContext.java.

5
6
7
8
9
10
11










12
13
14
15
16
17
18



19



























































// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;











/**
 * Stores the context for a thread.
 *
 * @since 2020/05/12
 */
public final class ThreadContext
{



}


































































>
>
>
>
>
>
>
>
>
>







>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.vm.springcoat.objects.SimpleObjectViewer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.ClassName;

/**
 * Stores the context for a thread.
 *
 * @since 2020/05/12
 */
public final class ThreadContext
{
	/** The current class path for this context. */
	private final List<VMClassLibrary> _classPath =
		new ArrayList<>();
	
	/** The class information pointers which exist currently. */
	private final Map<ClassName, SimpleObjectViewer> _classInfos =
		new HashMap<>();
	
	/**
	 * Obtains or loads a new class info context for the current thread.
	 *
	 * @param __worker The worker to operate under, for any method calls.
	 * @param __class The class to load.
	 * @return The object viewer for the class info.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/05/13
	 */
	public SimpleObjectViewer loadClassInfo(SpringThreadWorker __worker,
		ClassName __class)
		throws NullPointerException
	{
		if (__worker == null || __class == null)
			throw new NullPointerException("NARG");
		
		// Lock to prevent multiple threads from loading at once
		Map<ClassName, SimpleObjectViewer> classInfos = this._classInfos;
		synchronized (this)
		{
			// Check if already already to not load twice
			SimpleObjectViewer rv = classInfos.get(__class);
			if (rv != null)
				return rv;
			
			// Debug
			Debugging.debugNote("TC.loadClassInfos(%s)", __class);
			
			throw Debugging.todo();
		}
	}
	
	/**
	 * Pushes a library to the class path for this context.
	 *
	 * @param __lib The library to push.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/05/13
	 */
	public void pushClassPath(VMClassLibrary __lib)
		throws NullPointerException
	{
		if (__lib == null)
			throw new NullPointerException("NARG");
		
		// Debug
		Debugging.debugNote("TC.pushClassPath(%s)", __lib.name());
		
		// Do not allow multiple threads to push out of order
		synchronized (this)
		{
			this._classPath.add(__lib);
		}
	}
}

Changes to emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/objects/SimpleObjectViewer.java.

42
43
44
45
46
47
48
49
50
51
	/**
	 * {@inheritDoc}
	 * @since 2020/03/22
	 */
	@Override
	public SpringPointer pointer()
	{
		throw Debugging.todo();
	}
}







|


42
43
44
45
46
47
48
49
50
51
	/**
	 * {@inheritDoc}
	 * @since 2020/03/22
	 */
	@Override
	public SpringPointer pointer()
	{
		return this.pointer;
	}
}

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/jvm/JVMFunction.java.

5
6
7
8
9
10
11

12
13
14
15
16
17
18
..
25
26
27
28
29
30
31

























32
33
34
35
36
37
38
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm;


import cc.squirreljme.jvm.boot.SystemBoot;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.lang.ref.Reference;
import java.util.NoSuchElementException;

/**
 * This class contains the functions of the virtual machine.
................................................................................
	 * Not used.
	 *
	 * @since 2019/05/25
	 */
	private JVMFunction()
	{
	}

























	
	/**
	 * Checks if the given object can be stored in the array.
	 *
	 * @param __p The array pointer.
	 * @param __v The value to check.
	 * @return If this object can be stored in the array then {@code 1} will







>







 







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







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
26
27
28
29
30
31
32
33
34
35
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
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm;

import cc.squirreljme.jvm.boot.Allocator;
import cc.squirreljme.jvm.boot.SystemBoot;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.lang.ref.Reference;
import java.util.NoSuchElementException;

/**
 * This class contains the functions of the virtual machine.
................................................................................
	 * Not used.
	 *
	 * @since 2019/05/25
	 */
	private JVMFunction()
	{
	}
	
	/**
	 * Allocates raw memory for an object.
	 *
	 * @param __sz The number of bytes to allocate.
	 * @return The resulting allocated object.
	 * @throws IllegalArgumentException If the length is zero or negative.
	 * @throws OutOfMemoryError If there is no memory left.
	 * @since 2020/05/13
	 */
	public static long jvmAllocateRawObject(int __sz)
		throws IllegalArgumentException, OutOfMemoryError
	{
		// {@squirreljme.error ZZ4C Cannot allocate an object with zero or
		// negative size.}
		if (__sz <= 0)
			throw new IllegalArgumentException("ZZ4C");
		
		// Allocate memory region for an object
		long rv = Allocator.allocate(Allocator.CHUNK_BIT_IS_OBJECT, __sz);
		if (rv == 0)
			throw new OutOfMemoryError();
		
		return rv;
	}
	
	/**
	 * Checks if the given object can be stored in the array.
	 *
	 * @param __p The array pointer.
	 * @param __v The value to check.
	 * @return If this object can be stored in the array then {@code 1} will

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/jvm/LineEndingType.java.

12
13
14
15
16
17
18




19
20
21

22
23
24
25
26
27
28
29

30
/**
 * The type of line ending used.
 *
 * @since 2020/04/09
 */
public interface LineEndingType
{




	/** LF. */
	byte LF =
		0;

	
	/** CR. */
	byte CR =
		1;
	
	/** CRLF. */
	byte CRLF =
		2;

}







>
>
>
>


<
>



|



<
>

12
13
14
15
16
17
18
19
20
21
22
23
24

25
26
27
28
29
30
31
32

33
34
/**
 * The type of line ending used.
 *
 * @since 2020/04/09
 */
public interface LineEndingType
{
	/** Unspecified. */
	byte UNSPECIFIED =
		0;
	
	/** LF. */
	byte LF =

		1;
	
	/** CR. */
	byte CR =
		2;
	
	/** CRLF. */
	byte CRLF =

		3;
}

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/Allocator.java.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm.boot;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * This contains the static memory allocator.
 *
 * @since 2019/05/26
 */
@SuppressWarnings("FeatureEnvy")







<
<







7
8
9
10
11
12
13


14
15
16
17
18
19
20
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm.boot;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Constants;



/**
 * This contains the static memory allocator.
 *
 * @since 2019/05/26
 */
@SuppressWarnings("FeatureEnvy")

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/debug/Debugging.java.

367
368
369
370
371
372
373
374
375
376
377
378
379
380
381

382
383
384
385
386
387
		// Print it depending on what is desired
		switch (line)
		{
			case LineEndingType.CR:
				Debugging.__print('\r', null);
				break;
				
			case LineEndingType.CRLF:
				Debugging.__print('\r', '\n');
				break;
				
			case LineEndingType.LF:
				Debugging.__print('\n', null);
				break;
			

			default:
				Debugging.__print('$', null);
				break;
		}
	}
}







<
<
<
<



|
>

|




367
368
369
370
371
372
373




374
375
376
377
378
379
380
381
382
383
384
		// Print it depending on what is desired
		switch (line)
		{
			case LineEndingType.CR:
				Debugging.__print('\r', null);
				break;
				




			case LineEndingType.LF:
				Debugging.__print('\n', null);
				break;
				
			case LineEndingType.CRLF:
			default:
				Debugging.__print('\r', '\n');
				break;
		}
	}
}