Check-in [0bdf0d6e2c]

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

Overview
Comment:Minor work.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip-springcoat-bringup
Files: files | file ages | folders
SHA1: 0bdf0d6e2c0231459912082849d3ce443ab8833c
User & Date: stephanie.gawroriski 2020-05-13 19:54:46
Context
2020-05-13
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
15:48
Some base work. check-in: 47e4d0ab3f user: stephanie.gawroriski tags: wip-springcoat-bringup
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

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
...
281
282
283
284
285
286
287








288
289
290
291
292
293
294
295
296
297
298

package cc.squirreljme.vm.springcoat;

import cc.squirreljme.emulator.profiler.ProfilerSnapshot;
import cc.squirreljme.emulator.vm.VMResourceAccess;
import cc.squirreljme.emulator.vm.VMSuiteManager;
import cc.squirreljme.emulator.vm.VirtualMachine;

import cc.squirreljme.jvm.ConfigRomKey;
import cc.squirreljme.jvm.LineEndingType;
import cc.squirreljme.jvm.boot.ConfigWriter;
import cc.squirreljme.runtime.cldc.SquirrelJME;
import cc.squirreljme.runtime.cldc.asm.TaskAccess;

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.TreeMap;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * This class contains the instance of the SpringCoat virtual machine and has
 * a classpath along with all the needed storage for variables and such.
................................................................................
			this.mainClass);
		configWriter.writeUtfList(ConfigRomKey.MAIN_ARGUMENTS,
			this._args);
		configWriter.writeInteger(ConfigRomKey.LINE_ENDING,
			("\n".equals(File.separator) ? LineEndingType.LF :
			LineEndingType.CRLF));
		








		// ConfigRomKey.SYSCALL_STATIC_FIELD_POINTER
		// ConfigRomKey.SYSCALL_CODE_POINTER
		// ConfigRomKey.SYSCALL_POOL_POINTER
		// ConfigRomKey.BUILT_IN_ENCODING
		// ConfigRomKey.MICROEDITION_CONFIG
		
		// Define the class path
		VMClassLibrary[] classPathLibs = this.classloader.classPath();
		String[] classPath = new String[classPathLibs.length];
		for (int i = 0, n = classPath.length; i < n; i++)
			classPath[i] = classPathLibs[i].name();







>





>










>







 







>
>
>
>
>
>
>
>



<







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
...
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301

302
303
304
305
306
307
308

package cc.squirreljme.vm.springcoat;

import cc.squirreljme.emulator.profiler.ProfilerSnapshot;
import cc.squirreljme.emulator.vm.VMResourceAccess;
import cc.squirreljme.emulator.vm.VMSuiteManager;
import cc.squirreljme.emulator.vm.VirtualMachine;
import cc.squirreljme.jvm.BuiltInEncoding;
import cc.squirreljme.jvm.ConfigRomKey;
import cc.squirreljme.jvm.LineEndingType;
import cc.squirreljme.jvm.boot.ConfigWriter;
import cc.squirreljme.runtime.cldc.SquirrelJME;
import cc.squirreljme.runtime.cldc.asm.TaskAccess;
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;

/**
 * This class contains the instance of the SpringCoat virtual machine and has
 * a classpath along with all the needed storage for variables and such.
................................................................................
			this.mainClass);
		configWriter.writeUtfList(ConfigRomKey.MAIN_ARGUMENTS,
			this._args);
		configWriter.writeInteger(ConfigRomKey.LINE_ENDING,
			("\n".equals(File.separator) ? LineEndingType.LF :
			LineEndingType.CRLF));
		
		// Character encoding
		String meEncoding = Objects.toString(
			this._sysproperties.get("microedition.encoding"),
			System.getProperty("microedition.encoding"));
		configWriter.writeInteger(ConfigRomKey.BUILT_IN_ENCODING,
			(meEncoding == null ? BuiltInEncoding.UNSPECIFIED :
			CodecFactory.toBuiltIn(meEncoding)));
		
		// ConfigRomKey.SYSCALL_STATIC_FIELD_POINTER
		// ConfigRomKey.SYSCALL_CODE_POINTER
		// ConfigRomKey.SYSCALL_POOL_POINTER

		// ConfigRomKey.MICROEDITION_CONFIG
		
		// Define the class path
		VMClassLibrary[] classPathLibs = this.classloader.classPath();
		String[] classPath = new String[classPathLibs.length];
		for (int i = 0, n = classPath.length; i < n; i++)
			classPath[i] = classPathLibs[i].name();

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

355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
...
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
					catch (NoSuchElementException e)
					{
						throw new SystemCallException(__si,
							SystemCallError.NO_SUCH_CONFIG_KEY, e);
					}
			}
			
			// Call pure form as the supervisor has no way to handle this system
			// call either.
			return Assembly.sysCallPVL(__si,
				__a, __b, __c, __d, __e, __f, __g, __h);
		}
		
		// Error occurred, store it and return a default fail value
		catch (SystemCallException e)
		{
................................................................................
			Assembly.sysCallP(SystemCallIndex.ERROR_SET, __si, e.code);
			return 0;
		}
		
		// Unknown error occurred??
		catch (Throwable e)
		{
			e.printStackTrace();
			
			Assembly.sysCallP(SystemCallIndex.ERROR_SET, __si,
				SystemCallError.UNKNOWN);
			return 0;
		}
	}
}








|
|







 







|








355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
...
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
					catch (NoSuchElementException e)
					{
						throw new SystemCallException(__si,
							SystemCallError.NO_SUCH_CONFIG_KEY, e);
					}
			}
			
			// Call pure form as the supervisor has no way to handle this
			// system call either.
			return Assembly.sysCallPVL(__si,
				__a, __b, __c, __d, __e, __f, __g, __h);
		}
		
		// Error occurred, store it and return a default fail value
		catch (SystemCallException e)
		{
................................................................................
			Assembly.sysCallP(SystemCallIndex.ERROR_SET, __si, e.code);
			return 0;
		}
		
		// Unknown error occurred??
		catch (Throwable e)
		{
			Debugging.debugNote("Hiding sysCall exception...");
			
			Assembly.sysCallP(SystemCallIndex.ERROR_SET, __si,
				SystemCallError.UNKNOWN);
			return 0;
		}
	}
}

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

357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
	 */
	@SuppressWarnings("ConfusingArgumentToVarargsMethod")
	private static void __printLine()
	{
		// Get the line type used
		int line = Debugging._line;
		if (line == Integer.MIN_VALUE)
			Debugging._line = (line = Assembly.sysCallPV(
				SystemCallIndex.CONFIG_GET_VALUE, ConfigRomKey.LINE_ENDING));
		
		// Print it depending on what is desired
		switch (line)
		{
			case LineEndingType.CR:
				Debugging.__print('\r', null);







|







357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
	 */
	@SuppressWarnings("ConfusingArgumentToVarargsMethod")
	private static void __printLine()
	{
		// Get the line type used
		int line = Debugging._line;
		if (line == Integer.MIN_VALUE)
			Debugging._line = (line = Assembly.sysCallV(
				SystemCallIndex.CONFIG_GET_VALUE, ConfigRomKey.LINE_ENDING));
		
		// Print it depending on what is desired
		switch (line)
		{
			case LineEndingType.CR:
				Debugging.__print('\r', null);

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/i18n/DefaultLocale.java.

10
11
12
13
14
15
16

17
18
19
20
21
22
23
..
49
50
51
52
53
54
55



56
57
58
59
60
61
62







63
64
65
66
67
68
69
..
78
79
80
81
82
83
84
85


86




















package cc.squirreljme.runtime.cldc.i18n;

import cc.squirreljme.jvm.BuiltInLocale;
import cc.squirreljme.jvm.ConfigRomKey;
import cc.squirreljme.jvm.SystemCall;
import cc.squirreljme.jvm.boot.ConfigEntry;


/**
 * This class provides access to the default locale.
 *
 * @since 2018/09/20
 */
public final class DefaultLocale
................................................................................
	public static Locale defaultLocale()
	{
		Locale rv = DefaultLocale._default;
		if (rv != null)
			return rv;
		
		// The system could have configured the locale for us (hopefully)



		ConfigEntry locale = SystemCall.config(ConfigRomKey.BUILT_IN_LOCALE);
		switch (locale.getInteger())
		{
			case BuiltInLocale.ENGLISH_US:
			default:
				rv = new LocaleEnUs();
				break;







		}
		
		// Cache and use it
		DefaultLocale._default = rv;
		return rv;
	}
	
................................................................................
		Locale rv = DefaultLocale._noLocale;
		
		if (rv == null)
			DefaultLocale._noLocale = (rv = new LocaleEnUs());
		
		return rv;
	}
}





























>







 







>
>
>
|
|
|
|
|
|
|
>
>
>
>
>
>
>







 







|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
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
..
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

package cc.squirreljme.runtime.cldc.i18n;

import cc.squirreljme.jvm.BuiltInLocale;
import cc.squirreljme.jvm.ConfigRomKey;
import cc.squirreljme.jvm.SystemCall;
import cc.squirreljme.jvm.boot.ConfigEntry;
import java.util.NoSuchElementException;

/**
 * This class provides access to the default locale.
 *
 * @since 2018/09/20
 */
public final class DefaultLocale
................................................................................
	public static Locale defaultLocale()
	{
		Locale rv = DefaultLocale._default;
		if (rv != null)
			return rv;
		
		// The system could have configured the locale for us (hopefully)
		ConfigEntry locale;
		try
		{
			locale = SystemCall.config(ConfigRomKey.BUILT_IN_LOCALE);
			switch (locale.getInteger())
			{
				case BuiltInLocale.ENGLISH_US:
				default:
					rv = new LocaleEnUs();
					break;
			}
		}
		
		// If none was configured, assume the "no" locale which is enUS
		catch (NoSuchElementException e)
		{
			rv = DefaultLocale.noLocale();
		}
		
		// Cache and use it
		DefaultLocale._default = rv;
		return rv;
	}
	
................................................................................
		Locale rv = DefaultLocale._noLocale;
		
		if (rv == null)
			DefaultLocale._noLocale = (rv = new LocaleEnUs());
		
		return rv;
	}
	
	/**
	 * Returns the built-in encoding for the given string.
	 *
	 * @param __str The string to get the built-in encoding of.
	 * @return The built-in encoding from the string.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/05/13
	 */
	public static int toBuiltIn(String __str)
		throws NullPointerException
	{
		if (__str == null)
			throw new NullPointerException("NARG");
		
		switch (__str)
		{
			case "en-US":		return BuiltInLocale.ENGLISH_US;
			default:			return BuiltInLocale.UNKNOWN;
		}
	}
}

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/CodecFactory.java.

173
174
175
176
177
178
179
180
181






182
183
184
185
186
187
188
...
288
289
290
291
292
293
294















































295
296
297
298
299
300
301
	 * @return The default encoding.
	 * @since 2020/05/12
	 */
	public static int defaultEncoding()
	{
		try
		{
			return SystemCall.config(ConfigRomKey.BUILT_IN_ENCODING)
				.getInteger();






		}
		catch (NoSuchElementException e)
		{
			return BuiltInEncoding.UTF8;
		}
	}
	
................................................................................
		// {@squirreljme.error ZZ04 Unknown or unsupported encoding.
		// (The encoding)}
		catch (UnsupportedEncodingException e)
		{
			throw new RuntimeException(String.format("ZZ04 %s", __enc), e);
		}
	}















































	
	/**
	 * Normalizes the name of the encoding since there are so many aliases that
	 * way this code can operate very simply.
	 *
	 * @param __n The encoding to normalize.
	 * @return The normalized encoding, if it is not known then the input is







|

>
>
>
>
>
>







 







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







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
...
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
	 * @return The default encoding.
	 * @since 2020/05/12
	 */
	public static int defaultEncoding()
	{
		try
		{
			int rv = SystemCall.config(ConfigRomKey.BUILT_IN_ENCODING)
				.getInteger();
			
			// Default to UTF-8 if not specified here
			if (rv == BuiltInEncoding.UNSPECIFIED)
				return BuiltInEncoding.UTF8;
			
			return rv;
		}
		catch (NoSuchElementException e)
		{
			return BuiltInEncoding.UTF8;
		}
	}
	
................................................................................
		// {@squirreljme.error ZZ04 Unknown or unsupported encoding.
		// (The encoding)}
		catch (UnsupportedEncodingException e)
		{
			throw new RuntimeException(String.format("ZZ04 %s", __enc), e);
		}
	}
	
	/**
	 * Returns the built-in encoding for the given string.
	 *
	 * @param __str The string to find.
	 * @return The built-in encoding.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/05/13
	 */
	public static int toBuiltIn(String __str)
		throws NullPointerException
	{
		if (__str == null)
			throw new NullPointerException("NARG");
		
		switch (CodecFactory.__normalizeEncodingName(__str))
		{
			case "ascii":		return BuiltInEncoding.ASCII;
			case "ibm037":		return BuiltInEncoding.IBM037;
			case "iso-8859-1":	return BuiltInEncoding.ISO_8859_1;
			case "iso-8859-15":	return BuiltInEncoding.ISO_8859_15;
			case "utf-8":		return BuiltInEncoding.UTF8;
			default:			return BuiltInEncoding.UNSPECIFIED;
		}
	}
	
	/**
	 * Converts a built-in encoding to a string.
	 *
	 * @param __builtIn The built-in encoding.
	 * @return The string for this encoding.
	 * @since 2020/05/13
	 */
	public static String toString(int __builtIn)
	{
		switch (__builtIn)
		{
			case BuiltInEncoding.ASCII:			return "ascii";
			case BuiltInEncoding.IBM037:		return "ibm037";
			case BuiltInEncoding.ISO_8859_1:	return "iso-8859-1";
			case BuiltInEncoding.ISO_8859_15:	return "iso-8859-15";
			
				// Assume UTF-8
			case BuiltInEncoding.UTF8:
			default:							return "utf-8";
		}
	}
	
	/**
	 * Normalizes the name of the encoding since there are so many aliases that
	 * way this code can operate very simply.
	 *
	 * @param __n The encoding to normalize.
	 * @return The normalized encoding, if it is not known then the input is