Check-in [f03755ed49]

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

Overview
Comment:More fixings for the MLE error checking.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip-midlevel
Files: files | file ages | folders
SHA1: f03755ed494f43133253dd393e46eeafa39bf407
User & Date: stephanie.gawroriski 2020-06-30 02:39:54
Context
2020-06-30
02:54
Hopefully fix the last call and have all tests in cldc-compact passing? check-in: d8f6c1ca2d user: stephanie.gawroriski tags: wip-midlevel
02:39
More fixings for the MLE error checking. check-in: f03755ed49 user: stephanie.gawroriski tags: wip-midlevel
02:12
Fixes for Runtime and Terminal shelves. check-in: 468ce76e8f user: stephanie.gawroriski tags: wip-midlevel
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

253
254
255
256
257
258
259
260
261




262
263
264
265
266
267
268
269
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			return __thread.newInstance(
				MLEType.__type(__args[0]).getSpringClass(),




				new MethodDescriptor("()V"));
		}
	},
	
	/** {@link ObjectShelf#notify(Object, boolean)}. */
	NOTIFY("notify:(Ljava/lang/Object;Z)I")
	{
		/**







<
|
>
>
>
>
|







253
254
255
256
257
258
259

260
261
262
263
264
265
266
267
268
269
270
271
272
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{

			SpringClass type = MLEType.__type(__args[0]).getSpringClass();
			
			if (type.isArray())
				throw new SpringMLECallError("Cannot newInstance array");
			
			return __thread.newInstance(type, new MethodDescriptor("()V"));
		}
	},
	
	/** {@link ObjectShelf#notify(Object, boolean)}. */
	NOTIFY("notify:(Ljava/lang/Object;Z)I")
	{
		/**

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

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
..
49
50
51
52
53
54
55

















56
57
58
59
60
61
62
..
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
 * Functions for {@link ReferenceShelf}.
 *
 * @since 2020/06/18
 */
public enum MLEReference
	implements MLEFunction
{

































	/** {@link ReferenceShelf#linkGetObject(RefLinkBracket)}. */
	LINK_GET_OBJECT("linkGetObject:(Lcc/squirreljme/jvm/mle/brackets/" +
		"RefLinkBracket;)Ljava/lang/Object;")
	{
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
................................................................................
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			return MLEReference.__refLink(__args[0]).getObject();
		}
	},
































	
	/** {@link ReferenceShelf#linkSetObject(RefLinkBracket, Object)}. */
	LINK_SET_OBJECT("linkSetObject:(Lcc/squirreljme/jvm/mle/brackets/" +
		"RefLinkBracket;Ljava/lang/Object;)V")
	{
		/**
		 * {@inheritDoc}
................................................................................
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			MLEReference.__refLink(__args[0])
				.setObject((SpringObject)__args[1]);
			return null;
		}
	},

















	
	/** {@link ReferenceShelf#newLink()}. */
	NEW_LINK("newLink:()Lcc/squirreljme/jvm/mle/brackets/" +
		"RefLinkBracket;")
	{
		/**
		 * {@inheritDoc}
................................................................................
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			return ((SpringObject)__args[0]).refLink().get();




		}
	},
	
	/** {@link ReferenceShelf#objectSet(Object, RefLinkBracket)}. */
	OBJECT_SET("objectSet:(Ljava/lang/Object;" +
		"Lcc/squirreljme/jvm/mle/brackets/RefLinkBracket;)V")
	{
................................................................................
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			((SpringObject)__args[0]).refLink().set(
				(RefLinkObject)__args[1]);



			return null;
		}
	}
	
	/* End. */
	;
	







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







 







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







 







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







 







|
>
>
>
>







 







|
|
>
>
>







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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
...
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
...
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
194
195
 * Functions for {@link ReferenceShelf}.
 *
 * @since 2020/06/18
 */
public enum MLEReference
	implements MLEFunction
{
	/** {@link ReferenceShelf#deleteLink(RefLinkBracket)}. */
	DELETE_LINK("deleteLink:(Lcc/squirreljme/jvm/mle/brackets/" +
		"RefLinkBracket;)")
	{
		/**
		 * {@inheritDoc}
		 * @since 2020/06/29
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			// Check it, but otherwise do nothing
			MLEReference.__refLink(__args[0]);
			
			return null;
		}
	},
	
	/** {@link ReferenceShelf#linkGetNext(RefLinkBracket)}. */
	LINK_GET_NEXT("linkGetNext:(Lcc/squirreljme/jvm/mle/brackets/" +
		"RefLinkBracket;)Lcc/squirreljme/jvm/mle/brackets/RefLinkBracket;")
	{
		/**
		 * {@inheritDoc}
		 * @since 2020/06/29
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			return MLEReference.__refLink(__args[0]).getNext();
		}
	},
	
	/** {@link ReferenceShelf#linkGetObject(RefLinkBracket)}. */
	LINK_GET_OBJECT("linkGetObject:(Lcc/squirreljme/jvm/mle/brackets/" +
		"RefLinkBracket;)Ljava/lang/Object;")
	{
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
................................................................................
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			return MLEReference.__refLink(__args[0]).getObject();
		}
	},
	
	/** {@link ReferenceShelf#linkGetPrev(RefLinkBracket)}. */
	LINK_GET_PREV("linkGetPrev:(Lcc/squirreljme/jvm/mle/brackets/" +
		"RefLinkBracket;)Lcc/squirreljme/jvm/mle/brackets/RefLinkBracket;")
	{
		/**
		 * {@inheritDoc}
		 * @since 2020/06/29
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			return MLEReference.__refLink(__args[0]).getPrev();
		}
	},
	
	/** {@link ReferenceShelf#linkSetNext(RefLinkBracket, RefLinkBracket)}. */
	LINK_SET_NEXT("linkSetNext:(Lcc/squirreljme/jvm/mle/brackets/" +
		"RefLinkBracket;Lcc/squirreljme/jvm/mle/brackets/RefLinkBracket;)V")
	{
		/**
		 * {@inheritDoc}
		 * @since 2020/06/29
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			MLEReference.__refLink(__args[0]).setNext(
				MLEReference.__refLink(__args[1]));
			return null;
		}
	},
	
	/** {@link ReferenceShelf#linkSetObject(RefLinkBracket, Object)}. */
	LINK_SET_OBJECT("linkSetObject:(Lcc/squirreljme/jvm/mle/brackets/" +
		"RefLinkBracket;Ljava/lang/Object;)V")
	{
		/**
		 * {@inheritDoc}
................................................................................
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			MLEReference.__refLink(__args[0])
				.setObject((SpringObject)__args[1]);
			return null;
		}
	},
	
	/** {@link ReferenceShelf#linkSetPrev(RefLinkBracket, RefLinkBracket)}. */
	LINK_SET_PREV("linkSetPrev:(Lcc/squirreljme/jvm/mle/brackets/" +
		"RefLinkBracket;Lcc/squirreljme/jvm/mle/brackets/RefLinkBracket;)V")
	{
		/**
		 * {@inheritDoc}
		 * @since 2020/06/29
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			MLEReference.__refLink(__args[0]).setPrev(
				MLEReference.__refLink(__args[1]));
			return null;
		}
	},
	
	/** {@link ReferenceShelf#newLink()}. */
	NEW_LINK("newLink:()Lcc/squirreljme/jvm/mle/brackets/" +
		"RefLinkBracket;")
	{
		/**
		 * {@inheritDoc}
................................................................................
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			SpringObject object = (SpringObject)__args[0];
			if (!(object instanceof SpringSimpleObject))
				throw new SpringMLECallError("Invalid object"); 
			
			return object.refLink().get();
		}
	},
	
	/** {@link ReferenceShelf#objectSet(Object, RefLinkBracket)}. */
	OBJECT_SET("objectSet:(Ljava/lang/Object;" +
		"Lcc/squirreljme/jvm/mle/brackets/RefLinkBracket;)V")
	{
................................................................................
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			SpringObject object = (SpringObject)__args[0];
			if (!(object instanceof SpringSimpleObject))
				throw new SpringMLECallError("Invalid object"); 
			
			object.refLink().set(MLEReference.__refLink(__args[1]));
			return null;
		}
	}
	
	/* End. */
	;
	

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

204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			int index = (int)__args[0];
			if (index < 0 || index >= VMDescriptionType.NUM_TYPES)
				throw new SpringMLECallError(
					"Index out of range: " + index);
			
			switch (index)
			{
				case VMStatisticType.MEM_FREE:
					return Runtime.getRuntime().freeMemory();







|







204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			int index = (int)__args[0];
			if (index < 0 || index >= VMStatisticType.NUM_STATISTICS)
				throw new SpringMLECallError(
					"Index out of range: " + index);
			
			switch (index)
			{
				case VMStatisticType.MEM_FREE:
					return Runtime.getRuntime().freeMemory();

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

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











	volatile SpringObject _object;
	
	/** The next link in the chain. */
	volatile RefLinkObject _next;
	
	/** The previous link in the chain. */
	volatile RefLinkObject _prev;











	
	/**
	 * Returns the object that this points to.
	 *
	 * @return The object.
	 * @since 2020/06/13
	 */
	public final SpringObject getObject()
	{
		return this._object;
	}






















	
	/**
	 * Sets the object of this holder.
	 *
	 * @param __o The object to set.
	 * @since 2020/06/13
	 */
	public void setObject(SpringObject __o)
	{
		this._object = __o;
	}
}


















>
>
>
>
>
>
>
>
>
>
>











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











|
>
>
>
>
>
>
>
>
>
>
>
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
	volatile SpringObject _object;
	
	/** The next link in the chain. */
	volatile RefLinkObject _next;
	
	/** The previous link in the chain. */
	volatile RefLinkObject _prev;
	
	/**
	 * Gets the next link.
	 * 
	 * @return The link.
	 * @since 2020/06/29
	 */
	public RefLinkObject getNext()
	{
		return this._next;
	}
	
	/**
	 * Returns the object that this points to.
	 *
	 * @return The object.
	 * @since 2020/06/13
	 */
	public final SpringObject getObject()
	{
		return this._object;
	}
	
	/**
	 * Gets the previous link.
	 * 
	 * @return The link.
	 * @since 2020/06/29
	 */
	public RefLinkObject getPrev()
	{
		return this._prev;
	}
	
	/**
	 * Sets the next link.
	 * 
	 * @param __next The new link.
	 * @since 2020/06/29
	 */
	public void setNext(RefLinkObject __next)
	{
		this._next = __next;
	}
	
	/**
	 * Sets the object of this holder.
	 *
	 * @param __o The object to set.
	 * @since 2020/06/13
	 */
	public void setObject(SpringObject __o)
	{
		this._object = __o;
	}
	
	/**
	 * Sets the previous link.
	 * 
	 * @param __prev The new link.
	 * @since 2020/06/29
	 */
	public void setPrev(RefLinkObject __prev)
	{
		this._prev = __prev;
	}
}