Check-in [dc7c4033d2]

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

Overview
Comment:Add configuration lookups and otherwise, change the locale to be a bit different in how it works.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip-springcoat-bringup
Files: files | file ages | folders
SHA1: dc7c4033d29e652ef2047275533be8facdb8a561
User & Date: stephanie.gawroriski 2020-05-13 01:29:36
Context
2020-05-13
15:48
Some base work. check-in: 47e4d0ab3f user: stephanie.gawroriski tags: wip-springcoat-bringup
01:29
Add configuration lookups and otherwise, change the locale to be a bit different in how it works. check-in: dc7c4033d2 user: stephanie.gawroriski tags: wip-springcoat-bringup
00:01
Have ConfigEntry and ConfigReader just be iteration over that, ConfigEntry has all the parsing stuff. check-in: 5133c45caf user: stephanie.gawroriski tags: wip-springcoat-bringup
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/BuiltInLocale.java.





























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
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
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm;

/**
 * This represents a built-in locale.
 *
 * @since 2020/05/12
 */
public interface BuiltInLocale
{
	/** Unknown, will be treated as US English. */
	byte UNKNOWN =
		0;
	
	/** English: United States of America. */
	byte ENGLISH_US =
		1;
	
	/** The number of built-in locales. */
	byte NUM_BUILTIN_LOCALES =
		2;
}

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

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

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
138
139

140
141
142
143
144
145
146
147

148
149
150
151
152
153
154
155

156
157
158
159









160
161
162

163
164
	byte END =
		0;
	
	/**
	 * Java VM Version.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF}

	 */
	byte JAVA_VM_VERSION =
		1;
	
	/**
	 * Java VM Name.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF}

	 */
	byte JAVA_VM_NAME =
		2;
	
	/**
	 * Java VM Vendor.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF}

	 */
	byte JAVA_VM_VENDOR =
		3;
	
	/**
	 * Java VM E-Mail.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF}

	 */
	byte JAVA_VM_EMAIL =
		4;
	
	/**
	 * Java VM URL.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF}

	 */
	byte JAVA_VM_URL =
		5;
	
	/**
	 * The guest depth.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#INTEGER}

	 */
	@Deprecated
	byte GUEST_DEPTH =
		6;
	
	/**
	 * Main class.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF}

	 */
	byte MAIN_CLASS =
		7;
	
	/**
	 * Main program arguments.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF_LIST}

	 */
	byte MAIN_ARGUMENTS =
		8;
	
	/**
	 * Is this a MIDlet being launched?
	 *
	 * @squirreljme.configtype {@link ConfigRomType#BOOLEAN}

	 */
	byte IS_MIDLET =
		9;
	
	/**
	 * Define system property.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#KEY_VALUE_PAIR}

	 */
	byte DEFINE_PROPERTY =
		10;
	
	/**
	 * Classpath to use.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF_LIST}

	 */
	byte CLASS_PATH =
		11;
	
	/**
	 * System call static field pointer.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#LONG}

	 */
	byte SYSCALL_STATIC_FIELD_POINTER =
		12;
	
	/**
	 * System call method pointer.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#LONG}

	 */
	byte SYSCALL_CODE_POINTER =
		13;
	
	/**
	 * System call pool pointer.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#LONG}

	 */
	byte SYSCALL_POOL_POINTER =
		14;
	
	/**
	 * The built-in encoding to use, see {@link BuiltInEncoding}.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#INTEGER}

	 */
	byte BUILT_IN_ENCODING =
		15;
	
	/**
	 * The MicroEdition Configuration used, see {@link MicroeditionConfig}.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#INTEGER}

	 */
	byte MICROEDITION_CONFIG =
		16;
	
	/**
	 * The type of line ending to use, see {@link LineEndingType}.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#INTEGER}

	 */
	byte LINE_ENDING =
		17;
	









	/** Number of available configuration options. */
	byte NUM_OPTIONS =
		18;

}








>








>








>








>








>








>









>








>








>








>








>








>








>








>








>








>








>




>
>
>
>
>
>
>
>
>


<
>


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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187

188
189
190
	byte END =
		0;
	
	/**
	 * Java VM Version.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF}
	 * @since 2019/06/14
	 */
	byte JAVA_VM_VERSION =
		1;
	
	/**
	 * Java VM Name.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF}
	 * @since 2019/06/14
	 */
	byte JAVA_VM_NAME =
		2;
	
	/**
	 * Java VM Vendor.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF}
	 * @since 2019/06/14
	 */
	byte JAVA_VM_VENDOR =
		3;
	
	/**
	 * Java VM E-Mail.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF}
	 * @since 2019/06/14
	 */
	byte JAVA_VM_EMAIL =
		4;
	
	/**
	 * Java VM URL.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF}
	 * @since 2019/06/14
	 */
	byte JAVA_VM_URL =
		5;
	
	/**
	 * The guest depth.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#INTEGER}
	 * @since 2019/06/14
	 */
	@Deprecated
	byte GUEST_DEPTH =
		6;
	
	/**
	 * Main class.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF}
	 * @since 2019/06/14
	 */
	byte MAIN_CLASS =
		7;
	
	/**
	 * Main program arguments.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF_LIST}
	 * @since 2019/06/14
	 */
	byte MAIN_ARGUMENTS =
		8;
	
	/**
	 * Is this a MIDlet being launched?
	 *
	 * @squirreljme.configtype {@link ConfigRomType#BOOLEAN}
	 * @since 2019/06/14
	 */
	byte IS_MIDLET =
		9;
	
	/**
	 * Define system property.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#KEY_VALUE_PAIR}
	 * @since 2019/06/14
	 */
	byte DEFINE_PROPERTY =
		10;
	
	/**
	 * Classpath to use.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#UTF_LIST}
	 * @since 2019/06/14
	 */
	byte CLASS_PATH =
		11;
	
	/**
	 * System call static field pointer.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#LONG}
	 * @since 2019/06/14
	 */
	byte SYSCALL_STATIC_FIELD_POINTER =
		12;
	
	/**
	 * System call method pointer.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#LONG}
	 * @since 2019/06/14
	 */
	byte SYSCALL_CODE_POINTER =
		13;
	
	/**
	 * System call pool pointer.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#LONG}
	 * @since 2019/06/14
	 */
	byte SYSCALL_POOL_POINTER =
		14;
	
	/**
	 * The built-in encoding to use, see {@link BuiltInEncoding}.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#INTEGER}
	 * @since 2019/06/14
	 */
	byte BUILT_IN_ENCODING =
		15;
	
	/**
	 * The MicroEdition Configuration used, see {@link MicroeditionConfig}.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#INTEGER}
	 * @since 2019/06/14
	 */
	byte MICROEDITION_CONFIG =
		16;
	
	/**
	 * The type of line ending to use, see {@link LineEndingType}.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#INTEGER}
	 * @since 2019/06/14
	 */
	byte LINE_ENDING =
		17;
	
	/**
	 * The built-in locale the system is using, see {@link BuiltInLocale}.
	 *
	 * @squirreljme.configtype {@link ConfigRomType#INTEGER}.
	 * @since 2020/05/12
	 */
	byte BUILT_IN_LOCALE =
		18;
	
	/** Number of available configuration options. */
	byte NUM_OPTIONS =

		19;
}

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

8
9
10
11
12
13
14

15
16
17
18
19
20
21
...
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
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm;

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


/**
 * This class contains the functions of the virtual machine.
 *
 * @since 2019/05/25
 */
public final class JVMFunction
................................................................................
	 * @param __h Argument.
	 * @return The result.
	 * @since 2020/05/03
	 */
	public static long jvmSystemCallByTask(int __taskId, short __si,
		int __a, int __b, int __c, int __d, int __e, int __f, int __g, int __h)
	{


		// Depends on the system call type
		switch (__si)
		{
				// Query supported system calls
			case SystemCallIndex.QUERY_INDEX:
				switch (__a)
				{
					case SystemCallIndex.CONFIG_GET_VALUE:
					case SystemCallIndex.CONFIG_GET_TYPE:
						return 1;
					
					default:
						break;
				}
				break;
				
				// Get configuration key value
			case SystemCallIndex.CONFIG_GET_VALUE:


				return SystemBoot.config().rawValue(__a);
			






				// Get configuration key type
			case SystemCallIndex.CONFIG_GET_TYPE:


				return SystemBoot.config().type(__a);
		}

		





		// 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);


















	}
}








>







 







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



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

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.
 *
 * @since 2019/05/25
 */
public final class JVMFunction
................................................................................
	 * @param __h Argument.
	 * @return The result.
	 * @since 2020/05/03
	 */
	public static long jvmSystemCallByTask(int __taskId, short __si,
		int __a, int __b, int __c, int __d, int __e, int __f, int __g, int __h)
	{
		try
		{
			// Depends on the system call type
			switch (__si)
			{
					// Query supported system calls
				case SystemCallIndex.QUERY_INDEX:
					switch (__a)
					{
						case SystemCallIndex.CONFIG_GET_VALUE:
						case SystemCallIndex.CONFIG_GET_TYPE:
							return 1;
						
						default:
							break;
					}
					break;
					
					// Get configuration key value
				case SystemCallIndex.CONFIG_GET_VALUE:
					try
					{
						return SystemBoot.config().rawValue(__a);
					}
					catch (NoSuchElementException e)
					{
						throw new SystemCallException(__si,
							SystemCallError.NO_SUCH_CONFIG_KEY, e);
					}
				
					// Get configuration key type
				case SystemCallIndex.CONFIG_GET_TYPE:
					try
					{
						return SystemBoot.config().type(__a);
					}
					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;
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/RomReference.java.



































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
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
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.runtime.cldc.debug.Debugging;

/**
 * This represents a single ROM reference which is used to wrap the standard
 * long identifier used to refer to ROMs.
 *
 * @since 2020/05/12
 */
public final class RomReference
{
	/** The reference ID. */
	protected final long reference;
	
	/**
	 * Initializes the reference.
	 *
	 * @param __ref The ROM reference ID.
	 * @since 2020/05/12
	 */
	public RomReference(long __ref)
	{
		this.reference = __ref;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/05/12
	 */
	@Override
	public int hashCode()
	{
		throw Debugging.todo();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/05/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		throw Debugging.todo();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/05/12
	 */
	@Override
	public String toString()
	{
		throw Debugging.todo();
	}
}

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

5
6
7
8
9
10
11

12
13

14
15
16
17
18
19
20
..
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.runtime.cldc.debug.Debugging;
import java.io.UnsupportedEncodingException;


/**
 * This class contains helpers for all of the system calls to more reliably
 * have a type-safe and easier to use interface to them.
 *
 * @see SystemCallIndex
 * @since 2020/03/27
................................................................................
	 * Not used.
	 *
	 * @since 2020/03/27
	 */
	private SystemCall()
	{
	}







































	
	/**
	 * Returns the current task ID.
	 *
	 * @return The current task ID.
	 * @since 2020/05/03
	 */







>


>







 







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







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
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
// ---------------------------------------------------------------------------
// 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.ConfigEntry;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.io.UnsupportedEncodingException;
import java.util.NoSuchElementException;

/**
 * This class contains helpers for all of the system calls to more reliably
 * have a type-safe and easier to use interface to them.
 *
 * @see SystemCallIndex
 * @since 2020/03/27
................................................................................
	 * Not used.
	 *
	 * @since 2020/03/27
	 */
	private SystemCall()
	{
	}
	
	/**
	 * Looks up a configuration key that is available through the system call
	 * lookup for configuration items. A {@link ConfigEntry} will be composed
	 * to wrap and be able to access all the various values accordingly.
	 *
	 * @param __key The configuration key to lookup.
	 * @throws NoSuchElementException If this key is not found.
	 * @since 2020/05/12
	 */
	public static ConfigEntry config(int __key)
		throws NoSuchElementException
	{
		// We need the type to determine how to decode this entry
		int type = Assembly.sysCallV(SystemCallIndex.CONFIG_GET_TYPE, __key);
		
		// It is possible for an error to happen, so return this here
		int error = SystemCall.getError(SystemCallIndex.CONFIG_GET_TYPE);
		if (error != SystemCallError.NO_ERROR)
		{
			// {@squirreljme.error ZZ4E No such configuration item has the
			// specified key. (The key)}
			if (error == SystemCallError.NO_SUCH_CONFIG_KEY)
				throw new NoSuchElementException("ZZ4E " + __key);
			
			// {@squirreljme.error ZZ4F Other error while trying to access
			// configuration keys. (The key; The error)}
			throw new RuntimeException("ZZ4F " + __key + " " + error);
		}
		
		// {@squirreljme.error ZZ4G Could not get value of the configuration
		// item. (The key)}
		long rawValue = Assembly.sysCallVL(SystemCallIndex.CONFIG_GET_VALUE,
			__key);
		if (SystemCall.hasError(SystemCallIndex.CONFIG_GET_VALUE))
			throw new RuntimeException("ZZ4G " + __key);
		
		return new ConfigEntry(type, rawValue);
	}
	
	/**
	 * Returns the current task ID.
	 *
	 * @return The current task ID.
	 * @since 2020/05/03
	 */

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

68
69
70
71
72
73
74




75
76
77
78
79
80
81
...
156
157
158
159
160
161
162



163
164
165
166
167
168
169
170
	public static final byte NO_SUCH_THREAD =
		-12;
	
	/** Thread already has a context. */
	public static final byte THREAD_HAS_CONTEXT =
		-13;
	




	/**
	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallError()
	{
................................................................................
				return "NoSuchClass";
				
			case SystemCallError.NO_SUCH_THREAD:
				return "NoSuchThread";
			
			case SystemCallError.THREAD_HAS_CONTEXT:
				return "ThreadHasContext";



			
				// Some Other ID?
			default:
				return "ERROR" + __err;
		}
	}
}








>
>
>
>







 







>
>
>








68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
...
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
	public static final byte NO_SUCH_THREAD =
		-12;
	
	/** Thread already has a context. */
	public static final byte THREAD_HAS_CONTEXT =
		-13;
	
	/** No such configuration key. */
	public static final byte NO_SUCH_CONFIG_KEY =
		-14;
	
	/**
	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallError()
	{
................................................................................
				return "NoSuchClass";
				
			case SystemCallError.NO_SUCH_THREAD:
				return "NoSuchThread";
			
			case SystemCallError.THREAD_HAS_CONTEXT:
				return "ThreadHasContext";
			
			case SystemCallError.NO_SUCH_CONFIG_KEY:
				return "NoSuchConfigKey";
			
				// Some Other ID?
			default:
				return "ERROR" + __err;
		}
	}
}

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

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
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm.boot;

import cc.squirreljme.jvm.ConfigRomKey;
import cc.squirreljme.jvm.ConfigRomType;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.util.NoSuchElementException;

/**
 * Represents a configuration entry.
 *
 * @since 2020/04/03
 */
public final class ConfigEntry
{



















	/**
	 * {@inheritDoc}
	 * @since 2020/04/03
	 */
	@Override
	public boolean equals(Object __o)
	{


















		throw Debugging.todo();
	}
	
	/**
	 * Gets the string array from this configuration entry.
	 *
	 * @return The string array.







<











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







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







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
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm.boot;


import cc.squirreljme.jvm.ConfigRomType;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.util.NoSuchElementException;

/**
 * Represents a configuration entry.
 *
 * @since 2020/04/03
 */
public final class ConfigEntry
{
	/** The type of entry this is. */
	protected final int type;
	
	/** The raw value pointer. */
	protected final long rawValue;
	
	/**
	 * Initializes the configuration entry.
	 *
	 * @param __type The type used.
	 * @param __rawValue The raw pointer value.
	 * @since 2020/05/12
	 */
	public ConfigEntry(int __type, long __rawValue)
	{
		this.type = __type;
		this.rawValue = __rawValue;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/04/03
	 */
	@Override
	public boolean equals(Object __o)
	{
		throw Debugging.todo();
	}
	
	/**
	 * Returns the integer value of this configuration key.
	 *
	 * @return The value of the integer.
	 * @throws IllegalArgumentException If this entry does not refer to a value
	 * that is a integer.
	 * @since 2020/05/12
	 */
	public final int getInteger()
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ4D Entry is not compatible with integer.}
		if (this.type() != ConfigRomType.UTF_LIST)
			throw new IllegalArgumentException("ZZ4D");
		
		throw Debugging.todo();
	}
	
	/**
	 * Gets the string array from this configuration entry.
	 *
	 * @return The string array.

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

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
..
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
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.i18n;






/**
 * This class provides access to the default locale.
 *
 * @since 2018/09/20
 */
public final class DefaultLocale
{
	/** The locale to use for conversion in cases where one is not used. */
	public static final Locale NO_LOCALE =
		new LocaleEnUs();
	
	/** The default locale. */
	private static final Locale _DEFAULT_LOCALE =
		DefaultLocale.__defaultLocale();
	
	/**
	 * Not used.
	 *
	 * @since 2018/09/20
	 */
	private DefaultLocale()
................................................................................
	/**
	 * Returns the default locale, if one was not initialized yet then "en-US"
	 * will be used temporarily until one is.
	 *
	 * @return The default locale, this value should not be cached.
	 * @since 2018/09/20
	 */
	public static final Locale defaultLocale()
	{
		Locale rv = DefaultLocale._DEFAULT_LOCALE;
		if (rv == null)













			return DefaultLocale.NO_LOCALE;
		return rv;
	}
	
	/**
	 * Determines the default locale.
	 *
	 * @return The default locale.
	 * @since 2018/09/20
	 */
	private static Locale __defaultLocale()
	{
		// Use local from system property
		String prop = null;
		try
		{
			prop = System.getProperty("microedition.locale");
		}
		catch (SecurityException e)
		{
		}
		
		// If there is none, default to US
		if (prop == null)
			return new LocaleEnUs();
		
		// Determine the locale to use
		Locale use;
		switch (prop.toLowerCase())
		{
				// Fallback to en-US
			case "en-us":
			default:
				return new LocaleEnUs();
		}
	}
}








>
>
>
>
>







|
|
|


|
|







 







|

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




|

|
|

|

|
<
<
|
<
<
<
<
<
<
<
|
|

<
<
<
<
<
<
<
|
<



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
..
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
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

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
{
	/** The cached no locale. */
	private static Locale _noLocale =
		null;
	
	/** The default locale. */
	private static Locale _default =
		null;
	
	/**
	 * Not used.
	 *
	 * @since 2018/09/20
	 */
	private DefaultLocale()
................................................................................
	/**
	 * Returns the default locale, if one was not initialized yet then "en-US"
	 * will be used temporarily until one is.
	 *
	 * @return The default locale, this value should not be cached.
	 * @since 2018/09/20
	 */
	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;
	}
	
	/**
	 * Returns the the "no" locale.
	 *
	 * @return The no locale.
	 * @since 2020/05/12
	 */
	public static Locale noLocale()
	{
		Locale rv = DefaultLocale._noLocale;


		







		if (rv == null)
			DefaultLocale._noLocale = (rv = new LocaleEnUs());
		







		return rv;

	}
}

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

7
8
9
10
11
12
13


14
15

16
17
18
19
20
21
22
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164



















165
166
167
168
169
170
171
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.io;

import cc.squirreljme.jvm.BuiltInEncoding;


import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.io.UnsupportedEncodingException;


/**
 * This contains the code used to obtain the default encoding as well as
 * obtaining the encoder or decoder as needed.
 *
 * @since 2018/09/16
 */
................................................................................
	 * Returns the default decoder.
	 *
	 * @return The default decoder.
	 * @since 2018/10/13
	 */
	public static Decoder defaultDecoder()
	{
		return CodecFactory.decoder(Debugging.<Integer>todoObject());
	}
	
	/**
	 * Returns the default system encoder.
	 *
	 * @return The default encoder.
	 * @since 2018/09/16
	 */
	public static Encoder defaultEncoder()
	{
		return CodecFactory.encoder(Debugging.<Integer>todoObject());



















	}
	
	/**
	 * Returns a decoder that is based on a built-in one.
	 *
	 * @param __builtIn The {@link BuiltInEncoding}.
	 * @return The encoder that is built in.







>
>


>







 







|










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







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.io;

import cc.squirreljme.jvm.BuiltInEncoding;
import cc.squirreljme.jvm.ConfigRomKey;
import cc.squirreljme.jvm.SystemCall;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.io.UnsupportedEncodingException;
import java.util.NoSuchElementException;

/**
 * This contains the code used to obtain the default encoding as well as
 * obtaining the encoder or decoder as needed.
 *
 * @since 2018/09/16
 */
................................................................................
	 * Returns the default decoder.
	 *
	 * @return The default decoder.
	 * @since 2018/10/13
	 */
	public static Decoder defaultDecoder()
	{
		return CodecFactory.decoder(CodecFactory.defaultEncoding());
	}
	
	/**
	 * Returns the default system encoder.
	 *
	 * @return The default encoder.
	 * @since 2018/09/16
	 */
	public static Encoder defaultEncoder()
	{
		return CodecFactory.encoder(CodecFactory.defaultEncoding());
	}
	
	/**
	 * Returns the default encoding.
	 *
	 * @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;
		}
	}
	
	/**
	 * Returns a decoder that is based on a built-in one.
	 *
	 * @param __builtIn The {@link BuiltInEncoding}.
	 * @return The encoder that is built in.

Changes to modules/cldc-compact/src/main/java/java/lang/Character.java.

301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
...
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
	 * @return The converted character.
	 * @since 2018/10/13
	 */
	@ImplementationNote("CLDC only supports Latin-1 and this method has no " +
		"locale support.")
	public static char toLowerCase(char __c)
	{
		return DefaultLocale.NO_LOCALE.toLowerCase(__c);
	}
	
	/**
	 * Returns a string representation of the given character.
	 *
	 * @param __c The character to represent as a string.
	 * @return The string representation of that character.
................................................................................
	 * @return The converted character.
	 * @since 2018/10/13
	 */
	@ImplementationNote("CLDC only supports Latin-1 and this method has no " +
		"locale support.")
	public static char toUpperCase(char __c)
	{
		return DefaultLocale.NO_LOCALE.toUpperCase(__c);
	}
	
	/**
	 * Boxes the specified value.
	 *
	 * @param __v The value to box.
	 * @return The resulting character value.







|







 







|







301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
...
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
	 * @return The converted character.
	 * @since 2018/10/13
	 */
	@ImplementationNote("CLDC only supports Latin-1 and this method has no " +
		"locale support.")
	public static char toLowerCase(char __c)
	{
		return DefaultLocale.noLocale().toLowerCase(__c);
	}
	
	/**
	 * Returns a string representation of the given character.
	 *
	 * @param __c The character to represent as a string.
	 * @return The string representation of that character.
................................................................................
	 * @return The converted character.
	 * @since 2018/10/13
	 */
	@ImplementationNote("CLDC only supports Latin-1 and this method has no " +
		"locale support.")
	public static char toUpperCase(char __c)
	{
		return DefaultLocale.noLocale().toUpperCase(__c);
	}
	
	/**
	 * Boxes the specified value.
	 *
	 * @param __v The value to box.
	 * @return The resulting character value.

Changes to modules/cldc-compact/src/main/java/todo/TODO.java.

151
152
153
154
155
156
157

158
159
160
161
				// Could not use normal exit, so try this method
				Assembly.sysCallP(SystemCallIndex.FATAL_TODO);
			}
		
		// Build exception if not from an initializer
		if (__fromInit)
			return null;

		return new TODO(false, Arrays.asList(__args).toString());
	}
}








>
|



151
152
153
154
155
156
157
158
159
160
161
162
				// Could not use normal exit, so try this method
				Assembly.sysCallP(SystemCallIndex.FATAL_TODO);
			}
		
		// Build exception if not from an initializer
		if (__fromInit)
			return null;
		return new TODO(false, (__args == null ? null :
			Arrays.asList(__args).toString()));
	}
}